{"id":1829,"date":"2015-08-11T12:00:25","date_gmt":"2015-08-11T03:00:25","guid":{"rendered":"http:\/\/www.lookingatnothing.com\/?p=1829"},"modified":"2015-08-11T03:56:20","modified_gmt":"2015-08-10T18:56:20","slug":"holiday-post-image-vs-averaged-background-subtraction","status":"publish","type":"post","link":"https:\/\/lookingatnothing.com\/index.php\/archives\/1829","title":{"rendered":"Holiday post: image vs. averaged background subtraction"},"content":{"rendered":"<p>When correcting data for the many possible data artefacts, I usually prefer to do these corrections on the 2D images as opposed to the azimuthally averaged data (often referred to by the misnomer &#8220;integration&#8221;).<br \/>\nThis needs to be done for some direction-dependent corrections, such as for the polarization correction, but not necessarily for others. The background correction, for example, can be done in two ways: subtracting the background image (2D) from the measurement image, or subtracting the azimuthally averaged background data (1D) from the azimuthally averaged measured image.<br \/>\nTo illustrate the difference, perhaps a small demonstration can suffice.<!--more--><\/p>\n<h3>Set-up<\/h3>\n<p>We define two images: a background image and a sample measurement image. These are completely made-up images, and we give them the nice property that they represent scattering images in polar format: only Q varies along one axis, and only the azimuthal angle along the other.<br \/>\nWe imagine that there is a systematic instrumental contribution in the image: perhaps a small contribution from scattering off the edge of one of the slits or pinholes (streaking). Similar scattering can originate from capillary walls or imperfections in window material.<br \/>\nWe create two images (Figure 1), 16 by 20 pixels in size, that represent the background and sample measurement. The background image contains zero counts with Poisson noise added, and 30 pixels with an elevated intensity. The sample image is set up in a similar way, with Poisson noise added, and 30 pixels of elevated intensity, but has 20 counts of &#8220;signal&#8221; added.<\/p>\n<figure id=\"attachment_1834\" aria-describedby=\"caption-attachment-1834\" style=\"width: 300px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1834\" src=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11-300x113.png\" alt=\"Figure 1: Image subtraction of the background from the sample image. 30 pixels have elevated intensity, representing parasitic scattering. \" width=\"300\" height=\"113\" srcset=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11-300x113.png 300w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11-1024x384.png 1024w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11.png 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1834\" class=\"wp-caption-text\"><strong>Figure 1:<\/strong> Image subtraction of the background from the sample image. 30 pixels have elevated intensity, representing parasitic scattering.<\/figcaption><\/figure>\n<p>We can then attempt to retrieve the signal by subtraction of the background from the sample measurement in two ways: by subtracting the images followed by azimuthal averaging (Figure 1), or by azimuthal averaging followed by subtraction of the averaged data (Figure 2).<\/p>\n<figure id=\"attachment_1833\" aria-describedby=\"caption-attachment-1833\" style=\"width: 300px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig21.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1833\" src=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig21-300x75.png\" alt=\"Figure 2: Background subtraction using azimuthally averaged data from the first two images of Figure 1. The error bars show the standard error on the mean. The error bars on the subtracted data show the propagated uncertainties.\" width=\"300\" height=\"75\" srcset=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig21-300x75.png 300w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig21-1024x256.png 1024w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig21.png 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1833\" class=\"wp-caption-text\"><strong>Figure 2:<\/strong> Background subtraction using azimuthally averaged data from the first two images of Figure 1. The error bars show the standard error on the mean. The error bars on the subtracted data show the propagated uncertainties.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><\/h3>\n<h3>Conclusion<\/h3>\n<p>The conclusion is represented in Figure 3: both approaches result in the identical retrieval of 20 mean counts of signal after subtraction of the background. However, the region of elevated intensity results in a much higher uncertainty estimate on the data subtracted after azimuthal averaging. If we do image subtraction of the background before averaging, such spurious signals can &#8212; if they are stable in both measurements &#8212; leave no large detrimental effect.<\/p>\n<figure id=\"attachment_1839\" aria-describedby=\"caption-attachment-1839\" style=\"width: 300px\" class=\"wp-caption alignright\"><a href=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1839\" src=\"http:\/\/www.lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31-300x225.png\" alt=\"Figure 3: The difference between the two approaches, showing a much higher uncertainty when azimuthally averaging before background subtraction. \" width=\"300\" height=\"225\" srcset=\"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31-300x225.png 300w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31-1024x768.png 1024w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31-174x131.png 174w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31-70x53.png 70w, https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig31.png 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1839\" class=\"wp-caption-text\"><strong>Figure 3:<\/strong> The difference between the two approaches, showing a much higher uncertainty when azimuthally averaging before background subtraction. The error bars on the image-subtracted data show the standard error on the mean.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>When correcting data for the many possible data artefacts, I usually prefer to do these corrections on the 2D images as opposed to the azimuthally <a class=\"mh-excerpt-more\" href=\"https:\/\/lookingatnothing.com\/index.php\/archives\/1829\" title=\"Holiday post: image vs. averaged background subtraction\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":2,"featured_media":1834,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/lookingatnothing.com\/wp-content\/uploads\/2015\/08\/Fig11.png","jetpack_shortlink":"https:\/\/wp.me\/p1gZ2v-tv","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/1829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/comments?post=1829"}],"version-history":[{"count":4,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/1829\/revisions"}],"predecessor-version":[{"id":1843,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/posts\/1829\/revisions\/1843"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/media\/1834"}],"wp:attachment":[{"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/media?parent=1829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/categories?post=1829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lookingatnothing.com\/index.php\/wp-json\/wp\/v2\/tags?post=1829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}