フィルターのクリア

Saving the image after using regionprops

1 回表示 (過去 30 日間)
shru s
shru s 2017 年 6 月 19 日
コメント済み: shru s 2017 年 6 月 20 日
Hello, I am facing an issue with saving my image after cropping it. This is my image
But when i save my image i am getting this,
Could anyone tell me how I can save the image without the extra white area in the background? Thank you
edit: Here is my code
img = rgb2gray(imread('C:\Users\Shruthi\Desktop\project\A data\lazy.jpg'));
erodeImg = imerode(img,strel('disk',3));
imshow(erodeImg,[])
BW = bwlabel(erodeImg);
imshow(BW,[])
img = bwareaopen(BW,30);
pause(1)
[L Ne]=bwlabel(img);
regProp=regionprops(L,'BoundingBox');
hold on
for n=1:size(regProp,1)
rectangle('Position',regProp(n).BoundingBox,'EdgeColor','r','LineWidth',2)
end
figure;
imshow(img);
hold off
pause (1)
close
for n=1:Ne
[r,c] = find(L==n);
n1=img(min(r):max(r),min(c):max(c));
figure;
imshow(~n1);
saveas(figure(n),fullfile('C:\Users\Shruthi\Desktop\project\A data\SegmentedCharacters',['figure' num2str(n) '.jpg']));
end
and here is my image :
  2 件のコメント
Guillaume
Guillaume 2017 年 6 月 19 日
You would have to show us the code you're using for us to tell you what you're doing wrong.
shru s
shru s 2017 年 6 月 19 日
I have uploaded my code in my question. Kindly help me out.

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

採用された回答

Guillaume
Guillaume 2017 年 6 月 19 日
You're not saving the images per say, but saving the content of the figure window. Replace your saveas line with:
imwrite(~n1, fullfile('C:\Users\Shruthi\Desktop\project\A data\SegmentedCharacters', sprintf('image%d.jpg', n)));
  1 件のコメント
shru s
shru s 2017 年 6 月 20 日
wow! thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by