saving a processed image of the same size as the original for comparison

2 ビュー (過去 30 日間)
Stephen Devlin
Stephen Devlin 2018 年 5 月 11 日
コメント済み: Stephen Devlin 2018 年 5 月 11 日
I have an image (tif) which I import into Matlab, this becomes my reference.I draw a white line on it and save with the line on, I want to be able to check this lined image against the reference image but the image saved is not the same size as the reference image giving me an error. Any idea how I could compare the images?
Best regards, Steve
close all
clear all
clc
my_image = imread('liney.png');
my_image = my_image(:,:,1:3);
imshow(my_image);
A=(my_image);
im=(my_image);
imshow(im)
hold on
line([0 4487], [40 40],'Color','white');
hold on
title('line on')
hold on
Image = getframe(gcf);
imwrite(Image.cdata,'liney2.png')
B=imread('liney2.png');
Z = imabsdiff(B,A);
imshow(B)
hold on
imshow(Z,[])
Error:
*Error using checkForSameSizeAndClass (line 12) X and Y must be the same size.
Error in imabsdiff (line 42) checkForSameSizeAndClass(X, Y, mfilename);
Error in image_proc_04 (line 21) Z = imabsdiff(B,A);*

採用された回答

Guillaume
Guillaume 2018 年 5 月 11 日
If you have the computer vision toolbox you can use insertShape to draw directly into your image rather than a figure. This avoids all the problems with getframe or print.
  1 件のコメント
Stephen Devlin
Stephen Devlin 2018 年 5 月 11 日
Hi Guillaume, I don't have that toolbox yet, wanting to show how we can use Matlab for some image processing to build a case for having it for a project, expenditure is closely controlled at the moment.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by