Addition of more than one image is no not possible in for loop?

조회 수: 4 (최근 30일)
Jhilam Mukherjee
Jhilam Mukherjee 2014년 10월 12일
댓글: Jhilam Mukherjee 2014년 10월 13일
I want to segment an image region grow algorithm. I have taken seed points using getpts. My code is executed. I have obtained individual images in each iteration. But I want all segmented region in one image at last iteration. But I cannot get that. Please help me to overcome this problem.
close all;
I=imread('CT6.jpg');
I=im2double(I);
I=rgb2gray(I);
figure,imshow(I);
hold on;
[y x]=getpts;
n=length(x);
hold off;
J=zeros(10,10);
for i=1:n-1
x(i)=round(x(i));
y(i)=round(y(i));
J = regiongrowing(I,x(i),y(i),0.1);
%J=(J,J);
K=imadd(J,J)
figure,imshow(J);
end
figure,imshow(J);
  댓글 수: 5
Geoff Hayes
Geoff Hayes 2014년 10월 13일
@Image Analyst - I think that Jhilam means to add/layer all images on top of one another using imadd.
Image Analyst
Image Analyst 2014년 10월 13일
I added another answer after you pointed that out. See below.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 10월 13일
편집: Image Analyst 2014년 10월 13일
Try adding J to the prior K rather than to J (itself).
if i == 1
K = double(J);
else
K = K + J;
end
imshow(K, []);
drawnow;

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 10월 12일
Try using subplot() instead of using figure:
close all;
I=imread('CT6.jpg');
I=im2double(I);
I=rgb2gray(I);
figure,imshow(I);
hold on;
[y x]=getpts;
n=length(x);
hold off;
subPlotRows = ceil(sqrt(n));
J=zeros(10,10);
for i=1:n-1
x(i)=round(x(i));
y(i)=round(y(i));
J = regiongrowing(I,x(i),y(i),0.1);
%J=(J,J);
K=imadd(J,J)
subplot(subPlotRows, subPlotRows, i)
imshow(J);
end

Community Treasure Hunt

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

Start Hunting!

Translated by