I have tried to reconstruct a image using Motion Compensation technique. When i try to compare the image with SSIM i get an error like this.

3 views (last 30 days)
??? Error using ==> ne Matrix dimensions must agree.
Error in ==> ssim at 84 if (size(img1) ~= size(img2))
Error in ==> MCpredict_Full at 92 [mssim, ssim_map] = ssim(img1, img2);

Accepted Answer

Image Analyst
Image Analyst on 14 Jun 2014
Probably one image is color (3D) and the other is monochrome (2D). Simply type out the size array before you compare. It's best to do something like this:
[rows1, columns1, numberOfColorChannels1] = size(img1)
[rows2, columns2, numberOfColorChannels2] = size(img2)
if rows1~=rows2 || columns1~=columns2
% Warn user that sizes don't match......
You might have to also check on the number of color channels, depending on what operations you want to do.
  2 Comments
Image Analyst
Image Analyst on 16 Jun 2014
Edited: Image Analyst on 16 Jun 2014
You need to use conv2() on a 2D image - that's what the 2 means. If you want to convolve in 3D, which I highly doubt, you'd need to use convn(). To convolve a color image, you need to extract individual color channels, cast them to double, and then call conv2().
To display floating point images, you need to use [] in imshow:
imshow(y, []);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!