Addition of more than one image is no not possible in for loop?
Mostra commenti meno recenti
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 Commenti
Geoff Hayes
il 12 Ott 2014
Jhilam - please clarify what you mean by I want all segmented region in one image at last iteration. Do you want one image composed of all five, which you seem to be doing with
K = imadd(J,J);
at each iteration of the loop, or do you mean something else?
Jhilam Mukherjee
il 13 Ott 2014
Image Analyst
il 13 Ott 2014
Did you see my answer below? It does that. If you want all of them in a single axes rather than figure , then you can use montage().
Geoff Hayes
il 13 Ott 2014
@Image Analyst - I think that Jhilam means to add/layer all images on top of one another using imadd.
Image Analyst
il 13 Ott 2014
I added another answer after you pointed that out. See below.
Risposta accettata
Più risposte (1)
Image Analyst
il 12 Ott 2014
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
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!