How to eliminate uneven illumination from an imgae with respect to another image?

8 次查看(过去 30 天)
One of my approach is like this. I am not sure about this approach
1) There are two images im1 and im2. Extract the R G B content of im1.
2)Calculate the normalized value for each content
3)Reform a color image.
4)Repeat the process for im2
5)Compare each pixel and replace the content of im2 with im1.
I tried to normalize one of the image but didn't get a good output
Image_rgb = imread('aswathy_33_crop.jpg');
Image_rgb = double(Image_rgb);
figure;imshow(uint8(Image_rgb));
Image_red = Image_rgb(:,:,1);
Image_green = Image_rgb(:,:,2);
Image_blue = Image_rgb(:,:,3);
[row,col] = size(Image_rgb(:,:,1));
for y = 1:row
for x = 1:col
Red = Image_red(y,x);
Green = Image_green(y,x);
Blue = Image_blue(y,x);
if(Red == 0 && Green==0 && Blue==0)
Red = 1;
Green = 1;
Blue = 1;
end
NormalizedRed = Red/(Red + Green + Blue);
NormalizedGreen = Green/(Red + Green + Blue);
NormalizedBlue = Blue/(Red + Green + Blue);
Image_red(y,x) = NormalizedRed;
Image_green(y,x) = NormalizedGreen;
Image_blue(y,x) = NormalizedBlue;
end
end
Image_rgb(:,:,1) = Image_red;
Image_rgb(:,:,2) = Image_green;
Image_rgb(:,:,3) = Image_blue;
new_image1 = cat(3, Image_rgb(:,:,1) ,Image_rgb(:,:,2), Image_rgb(:,:,3));
figure; imshow(uint8(255*new_image1));
  5 个评论
aswathy nair
aswathy nair 2015-5-27
Sorry I forgot to save the edit. Can you please suggest me whether my approach is correct or not based on my question.

请先登录,再进行评论。

回答(2 个)

B.k Sumedha
B.k Sumedha 2015-5-27
Image=imread('aswathy_33_crop.jpg');
Image_rgb =Image;
Image_rgb = imresize(Image_rgb, [400 400]);
Image_rgb = double(Image_rgb);
%figure;imshow(uint8(Image_rgb));
Image_red = Image_rgb(:,:,1);
Image_green = Image_rgb(:,:,2);
Image_blue = Image_rgb(:,:,3);
%figure;imshow(uint8(Image_red));
[row,col] = size(Image_rgb(:,:,1));
for y = 1:row %-->numberof rows in image
for x = 1:col %-->number of columns in the image
Red = Image_red(y,x);
Green = Image_green(y,x);
Blue = Image_blue(y,x);
NormalizedRed = Red/sqrt(Red^2 + Green^2 + Blue^2);
NormalizedGreen = Green/sqrt(Red^2 + Green^2 + Blue^2);
NormalizedBlue = Blue/sqrt(Red^2 + Green^2 + Blue^2);
Image_red(y,x) = NormalizedRed;
Image_green(y,x) = NormalizedGreen;
Image_blue(y,x) = NormalizedBlue;
end
end
Image_rgb(:,:,1) = Image_red;
Image_rgb(:,:,2) = Image_green;
Image_rgb(:,:,3) = Image_blue;
Image_rgb = Image_rgb .* Image_rgb;
imshow(Image_rgb);
Try with this

Image Analyst
Image Analyst 2025-7-11
No, that won't do it. And I don't know what you mean by with respect to another image. The best way to flatten out an image to "undo" the non-uniform illumination is to snap an image of a uniform white or gray sheet and then convert this to a "percentage" image where each pixel is the percentage of the max gray level in the image. Then take your sample/test image and divide it by the percentage image. This will make it as if every pixel in your image had the same illumination (exposure) as the brightest pixel in your image.
See attached demos.
Another good way to flatten out the non-uniform illumination, if you don't have an image of a blank, uniform scene, is to call adapthisteq. It is less optimal than the way where you divide by the blank shot.

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by