hi ,I processed images on a folder. Now I want to save all the processed photos in the folder, but only the last photo is saved, what should I do?

3 ビュー (過去 30 日間)
hi ,I processed images on a folder. Now I want to save all the processed photos in the folder, but only the last photo is saved, what should I do?
.......
for y=1:160
x_theta=image_resize(x,y)*cos(theta)+image_resize(x,y)*sin(theta);
y_theta=-image_resize(x,y)*sin(theta)+image_resize(x,y)*cos(theta);
gb(x,y)= exp(-(x_theta.^2/2*bw^2+ gamma^2*y_theta.^2/2*bw^2))*cos(2*pi/lambda*x_theta+psi);
end
end
% figure(2);
% imshow(gb);
% title('filtered image');
Y1= imtophat(gb, strel('disk', 150));
% figure, imshow(Y1,[]);
Y2= imadjust(Y1);
% figure,imshow(Y2);
level=graythresh(Y2);
BW=im2bw(Y2,level);
% figure, imshow(BW);
C=~BW;
% figure, imshow(C);
D= -bwdist(C);
D(C)= -Inf;
L=watershed(D);
Wi=label2rgb(L, 'hot', 'w');
% figure,subplot(1,2,1), imshow (Wi);
im= gb;
im(L==0)=0;
% subplot(1,2,2), imshow (im,[]);
end
imwrite(im,'new.png')

回答 (1 件)

DGM
DGM 2022 年 5 月 15 日
編集済み: DGM 2022 年 5 月 15 日
Considering that there's missing code and open scopes, we're left to guess whether anything is inside of a loop or not. Either way, it should be obvious that
imwrite(im,'new.png')
only writes an array to one file -- the same file every time. You're the only one who knows where this is in your code, so you'll have to figure out whether this is even being called more than once.
There are many examples of processing sequences of files
  3 件のコメント
Stephen23
Stephen23 2022 年 5 月 15 日
@pantea sam: because im is exactly the same on every loop iteration.
pantea sam
pantea sam 2022 年 5 月 16 日
@Stephen23 How should I write?
The im(k).name I use gives me white images

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

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by