{"id":1348,"date":"2017-05-10T18:36:24","date_gmt":"2017-05-10T09:36:24","guid":{"rendered":"http:\/\/rageworx.info\/?p=1348"},"modified":"2017-05-10T18:36:24","modified_gmt":"2017-05-10T09:36:24","slug":"correcting-shaded-illumination-on-medical-image","status":"publish","type":"post","link":"https:\/\/rageworx.info\/?p=1348","title":{"rendered":"Correcting shaded illumination on medical image."},"content":{"rendered":"<p>By using CLAHE algorithm, there&#8217;s some problem occurs by object shapes like this:<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1350\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe_wlvl.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Each edge side of object going too darken by window leveling. It is defecting issue of CLAHE. So I tried to make it corrected with shading correction.<\/p>\n<p>Here is source raw image, 14bit gray.<br \/>\n<a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1352\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>First, I need make a background mask to overriding changed level after CLAHE.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1353\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcrawimg_bgmasked.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>It can generate simply by using my librawprocessor. Then I applied CLAHE, 10&#215;10, 30.0f.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1349\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_clahe.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Shadowed or shaded areas occurs after applying CLAHE, it must be corrected. So I made shaded map with my fast resize engine. Down scale to 10% of original image size with Bi-Linear filter, then up scale again with B-Spline filter with inverse.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1351\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/srcimg_shade_correct_masked.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>It is much effective than Gaussian blur. Very fast but similar to Gaussian blurred. almost realtime in 3000&#215;3000 array with floating point\u00a0 levels in AVX and OpenMP optimization.<\/p>\n<p>Now I am just add masked shade map level with exponential to original image.<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"Applying shade mask to CLAHE\">{\r\n    if ( ( src == NULL ) || ( smap == NULL ) )\r\n        return;\r\n\r\n    if ( src-&gt;Width() != smap-&gt;Width() )\r\n        return;\r\n\r\n    if ( src-&gt;Height() != smap-&gt;Height() )\r\n        return;\r\n\r\n    float* datasrc = src-&gt;Data();\r\n    float* datamap = smap-&gt;Data();\r\n\r\n    #pragma omp parellel for\r\n    for( unsigned cnt=0; cnt&lt; src-&gt;Size(); cnt++ )\r\n    {\r\n        float diffs = datamap[ cnt ];\r\n\r\n        if ( diffs &gt; 0.0f )\r\n        {\r\n            datasrc[ cnt ] += exp( diffs );\r\n        }\r\n    }<\/pre>\n<p>Result is :<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1354\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_no_bg.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Shaded object areas seems to enhanced than before. So I continued to applying background mask.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1355\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_w_bg.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Ok, then I made it to window leveled.<\/p>\n<p><a href=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1356\" src=\"http:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl-500x500.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl-500x500.png 500w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl-200x200.png 200w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl-300x300.png 300w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl-150x150.png 150w, https:\/\/rageworx.info\/wp-content\/uploads\/2017\/05\/mixedimg_wlvl.png 615w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Each edge sides are not seems to much shaded than before. It should be better than applying single CLAHE. I will continue to write more effective image processing with CLAHE.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By using CLAHE algorithm, there&#8217;s some problem occurs by object shapes like this: Each edge side of object going too darken by window leveling. It is defecting issue of CLAHE. So I tried to make it corrected with shading correction. Here is source raw image, 14bit gray. First, I need&#8230; <a href=\"https:\/\/rageworx.info\/?p=1348\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,445,438,3],"tags":[507,509,195,446,508],"class_list":["post-1348","post","type-post","status-publish","format-standard","hentry","category-development","category-examination","category-medical","category-raphs","tag-clahe","tag-correction","tag-image","tag-medical","tag-shade"],"_links":{"self":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts\/1348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1348"}],"version-history":[{"count":0,"href":"https:\/\/rageworx.info\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions"}],"wp:attachment":[{"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rageworx.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}