我試圖去除兩幅圖像中的照度變化。我的一個辦法是:rgb圖像的規範化
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.
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));
這是單個圖像,其在與完全扭曲最終崩潰image.Can有人建議我要去的地方錯了,是否只歸我的辦法處理這一問題是對還是不?
輸入1
輸入2
不知道你實際上是試圖實現,但如果你想刪除光照不均勻,你可以看看我的答案在這裏... http://stackoverflow.com/questions/27891944/detect-quite-brighter-spots-on-the-image/27893051#27893051 –
@Mark Setchell我在這篇文章中添加了兩張圖片。這兩幅圖像是相同的,並且在相同的情況下拍攝。但是我們可以看到它有一個顏色變化,這是由於照明的差異。我想從圖像中刪除這兩個看起來相似。 –
'New_Image = rgb2gray(Image_rgb)'? –