Comparing 2 images intensities

down votefavorite
I have two images 1 and 2. I want to get the v (intensity) value of the hsv images; then I want the v (intensity) value of the first image equal to v (intesity) value of the second image?
I used this code to get the v;
v = image1(:, :, 3);
u = image2(:, :, 3);
How do I make both u and v the same value?
Thanks

回答 (2 件)

Jeff E
Jeff E 2014 年 2 月 6 日

1 投票

The code below will take the hue and saturation values from image1, and the value from image2, and merge them into one new image. Said another way, you are replacing the V signal from image1 with the V signal from image2.
new_image1 = cat(3, image1(:,:,1) , image1(:,:,2), image2(:,:,3));
Your last question "How do I make both u and v the same value?" doesn't make sense, to me.

1 件のコメント

Ramo
Ramo 2014 年 2 月 8 日
Its because i had two images of the same scene that are taken at different times, therefore the two images will have different intensities. So now i want to equalise their intesities so they look the same.

サインインしてコメントする。

Image Analyst
Image Analyst 2014 年 2 月 8 日

1 投票

Try something like this:
hsv1 = rgb2hsv(rgbImage1); % Convert to hsv color space.
hsv2 = rgb2hsv(rgbImage2); % Convert to hsv color space.
hsvOut = hsv1; % Initialize output array.
hsvOut(:,:,3) = hsv2(:,:,3); % Replace intensity of 1 with 2
rgbOut = rgb2hsv(hsvOut); % convert back to rgb color space.

7 件のコメント

Ramo
Ramo 2014 年 2 月 9 日
編集済み: Ramo 2014 年 2 月 9 日
I have tried this:
V1 = rgb2hsv(image1);
V2 = rgb2hsv(image2);
v1 = V1(:, :, 3);
v2 = V1(:, :, 3);
hsvOut = 0.5*(v1+ v2);
imshow(hsvOut)
%It wont convert back to rgb ?
rgbOut = hsv2rgb(hsvOut);
figure; imshow(rgbOut)
Thanks,
Image Analyst
Image Analyst 2014 年 2 月 9 日
Yeah, of course that won't work because hsvOut is not a 3D image. Plus v1 and v2 are both the same thing: the v channel of V1. Why did you not want to do what I suggested? Try it like I said instead.
Ramo
Ramo 2014 年 2 月 13 日
Your way doesnt work too!?
what about something like that:
y = rgb2hsv(base);
x = rgb2hsv(unregistered);
v1 = y(:,:,3);
v2 = x(:,:,3);
v3 = zeros(size(v1));
g = size(v1);
x_axis = g(1);
y_axis = g(2);
for i = 1:x_axis,
for j = 1:y_axis,
v3(j) =0.5*( v1(j)+ v2(j));
end
end
%to put the calculated value into the other matrix
for k = 1:x_axis,
for l = 1:y_axis,
v1(l) = v3(j);
end
end
%putting the images together
final = zeros(x_axis, y_axis,3);
final(:,:,1) = y(:,:,1);
final(:,:,2) = y(:,:,2);
final(:,:,3) = v1;
%converting back to rgb
final1 = hsv2rgb(final);
figure; imshow(final1)
Thanks,
Image Analyst
Image Analyst 2014 年 2 月 13 日
You say
v3(j) =0.5*( v1(j)+ v2(j));
so you're not replacing 1 with 2, you're replacing 1 with the average of image 1 and 2, which is not what you originally asked, though it may be what you want.
Ramo
Ramo 2014 年 2 月 13 日
Thats true, because if the difference between the two intensities of the images are big then working the average would give you a better result (less noise too)- that's what I thought. However I wouldn't mind using either methods as long as it works!
Image Analyst
Image Analyst 2014 年 2 月 13 日
So are we done here? If so, please mark my answer as Accepted. Thanks.
Ramo
Ramo 2014 年 2 月 13 日
編集済み: Ramo 2014 年 2 月 13 日
Your code didn't work though. however i voted you!

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 2 月 6 日

編集済み:

2014 年 2 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by