필터 지우기
필터 지우기

Launch an algorithm in several samples extracted from an image

조회 수: 1 (최근 30일)
Rdmato33
Rdmato33 2015년 10월 13일
댓글: Thorsten 2015년 10월 14일
Hello, I would like to extract features of a raster image by using an active contour algorithm (see below). My goal is to obtain morphometry of each object. For each of them (92 features), I have created same size matrix (5 rows, 5 columns) with this code :
%svf is the name of the image
%xy_points are the center coordinates of each feature
For m=1:92;a(:,:,m)=svf(xy_points(m,1)-2:xy_points(m,1)+2,xy_points(m,2)-2:xy_points(m,2)+2);end
Thus, I obtained 92 matrix of 5x5.
This is my problem : I have succeeded in applying the active contour algorithm on 1 image (the whole image called "svf"). But I don't know how to apply it on my samples (matrix for each feature) and to repeat the process.
Thanks for your help.

답변 (1개)

Thorsten
Thorsten 2015년 10월 13일
Why not
for m=1:92;
result = activecontour(svf(xy_points(m,1)-2:xy_points(m,1)+2,xy_points(m,2)-2:xy_points(m,2)+2));
% do something with result
end
  댓글 수: 2
Rdmato33
Rdmato33 2015년 10월 13일
편집: Rdmato33 2015년 10월 13일
Thanks for you answer. Actually, I use a different algorithm than "activecontour". As you can see below, the code is more complex. Do I have to insert your code at the beginning of the algorithm (at the step of resizing)?
imwrite(svf,'../images/svf.pgm');
[I,map] = rawread('../images/svf.pgm');
I=imresize(I,1);
disp(' Compute edge map ...');
f = 1 - I/255;
f0 = gaussianBlur(f,1);
[px,py] = gradient(f0);
figure(1);
subplot(121); imdisp(-f); title('snake potential');
subplot(122); quiver(px,py);
axis('image', 'ij', 'off');
title('traditional force');
disp(' ');
disp(' Press any key to start the deformation');
pause;
figure(1); subplot(121);
colormap(gray(64));
image(((1-f)+1)*40); axis('square', 'off');
figure, imshow(I,map);
colormap(gray(64));
t = 0:0.5:1;
x = 120
y = 20
[x,y] = snakeinterp(x,y,2,0.5);
snakedisp(x,y,'r')
pause(1);
for i=1:20,
[x,y] = snakedeform2(x,y,0.05,0,1, 2, 0.15,px,py,5);
[x,y] = snakeinterp(x,y,2,0.5);
snakedisp(x,y,'r')
title(['Deformation in progress, iter = ' num2str(i*5)])
pause(0.1);
end
disp(' ');
disp(' Press any key to display the final result');
pause;
figure(1); subplot(121);
colormap(gray(64));
image(((1-f)+1)*40); axis('square', 'off');
snakedisp(x,y,'r');
title(['Final result, iter = ' num2str(i*5)]);
Thorsten
Thorsten 2015년 10월 14일
Your code has various issues:
. if you have swf as your image, why do you write it to a pgm image, then read it, instead on just working with swf
. why to you scale with 1, i.e., no scaling?
Besides this, my suggestion was to write a function activecontour with the image as an argument, that you then call in a loop over all your subimages.

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

Community Treasure Hunt

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

Start Hunting!

Translated by