how to save the cropped image in to list and add

1 次查看(过去 30 天)
i wanted the cropped image to save and then add all those area of the cropped image
{projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002';
%y = 72;
X = zeros(128, 128, 1, 72,'uint16');
% Read the series of images.
% for p=1
p=1;
thisfile = sprintf('IM_%d.dcm', p);
filename = fullfile( projectdir, thisfile );
imdata = dicomread(filename);
imsize = size(imdata);
if ~isequal( imsize, [128 128 1 72] )
fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename);
else
X(:, :, :, :,p) = imdata;
end
figure();
montage(X(:,:,:,:,p), [0 100])
a=zeros(128,128,72) ;
for i=1:18
a=getpix(X(:,:,:,i));%i have a function with getpix(grayscale) to crop the image
a.list();
% u=edge(a,'canny','both');
% v{i}=bwmorph(u,'skel',inf);
% %v=bwmorph(u,'skel',inf);
% figure()
% montage(a,[0 100])
end}
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in Untitled8 (line 22)
a(i)=getpix(X(:,:,:,i));

回答(1 个)

KSSV
KSSV 2016-12-9
In
a(i)=getpix(X(:,:,:,i));
Check the size of getpix(X(:,:,:,i)) and assign it to a. Here you have considered a as vector but the output getpix(X(:,:,:,i)) is not a number, it seems to be a array/ matrix.
Read about debuger in matlab. It help you in understanding code a lot.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by