Showing posts with label charecter segmentation. Show all posts
Showing posts with label charecter segmentation. Show all posts

Wednesday, November 25, 2009

charecter segmentation matlab


we will use the above image for processing

1.add the image to matlab work space

ch=imread('char.jpg');

2.convert the RGB image to gray scale using rgb2gray function
Gch=rgb2gray(ch);

3.convert this gray scale image to BW comparing with some threshold
bw= im2bw(Gch,graythresh(Gch));

now u will get a binary image containing 1 r 0 's which will be easy to process

4. find the edge's in that binary image
Ibw= edge(uint8(bw));
imshow(Ibw);

5.using Morphological process to enhance the image
se = strel('disk',4);
bw2 = imdilate(Ibw, se);
imshow(bw2);



6. filling the holes in the dilated image
fill= imfill(bw2,'holes');
imshow(fill)
7. labeling the parts of the image and marking their position
[lab n] = bwlabel(fill);
props = regionprops(lab);
Z = [props.BoundingBox];
Z= reshape(Z,[4 n]);


8. display the results
imshow(I);
hold on;
for i = 1:n
rectangle('position',z(:,i),'edgecolor','r');
end


this can be used with a neural network to recognize patterns
we will see how to do this in next blog