To store segmented images in a separate folder/file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm segmenting characters from a document image using the following code. I want to store the segmented characters in a folder from where i could use those individual images for recognition.
%%Image segmentation and extraction
%%Read Image
global Ipro
imagen=Ipro;
%%Show image
%figure(1)
%imshow(imagen);
%title('INPUT IMAGE WITH NOISE')
%%Convert to gray scale
if size(imagen,3)==3 % RGB image
imagen=rgb2gray(imagen);
end
%%Convert to binary image
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
%%Remove all object containing fewer than 30 pixels
imagen = bwareaopen(imagen,30);
pause(1)
%%Show image binary image
%figure(2)
%imshow(~imagen);
%title('INPUT IMAGE WITHOUT NOISE')
%%Label connected components
[L Ne]=bwlabeln(imagen);
%%Measure properties of image regions
propied=regionprops(L,'BoundingBox');
hold on
%%Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
%hold off
%pause (1)
%%Objects extraction
%figure
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
axes(handles.axes4)
imshow(~n1);
title('Segmented Characters');
pause(0.5)
end
Please help out.
0 Commenti
Risposte (1)
Image Analyst
il 17 Mag 2013
In your loop at the bottom, insert these lines
% Construct filename for this particular image.
baseFileName = sprintf('image %d.png', n);
% Specify yourFolder in advance.
% Prepend the folder to make the full file name.
fullFileName = fullfile(yourFolder, baseFileName);
% Do the write to disk.
imwrite(n1, fullFileName);
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!