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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
aswathy nair
aswathy nair il 27 Mag 2015
Sorry I forgot to save the edit. Can you please suggest me whether my approach is correct or not based on my question.

Accedi per commentare.

Risposte (1)

B.k Sumedha
B.k Sumedha il 27 Mag 2015
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

Community Treasure Hunt

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

Start Hunting!

Translated by