Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how to crop an image from Segout and bwoutline function?? *help
Replies: 4   Last Post: Aug 16, 2013 3:09 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dipti chaudhary

Posts: 11
Registered: 12/16/09
Re: how to crop an image from Segout and bwoutline function?? *help
Posted: Jan 3, 2013 11:46 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Rierien Merischaputri" <rierien.jessyntha.m@mail.ugm.ac.id> wrote in message <kbhni8$92b$1@newscl01ah.mathworks.com>...
> Hi everyone,
> I am a student which still in thesis research to build an algorithm for pattern recognition in numerical image (in my case: to recognize number of electricity bill in electricity home machine)
>
> now, I have build the boundary of the original image
> but I've got stuck for the next step (to crop image)
>
> is there anyone who can help me, which function do I have to choose?
> or, is there any demo which can I follow?
>
> Thanks before, :)
>
> note: this the link which connect to the picture for my syntax
> https://twitter.com/jessynthaputri/status/284311199275954179/photo/1
>
> syntax:
> coba1 = imread ('D:\day of dare\sem 7\TA\Jessyntha\foto\9.jpg');
> figure, imshow (coba1);
> J=rgb2gray(coba1);
> figure, imshow (J);
> ved=edge(J,'prewitt');
> imshow (ved);
> cp=bwareaopen(ved,5);
> figure, imshow (cp), title ('after cleaning phase');
>
>
> se90 = strel('line',5,90);
> se0 = strel ('line',5,0);
> BWsdil = imdilate(cp, [se90 se0]);
> figure, imshow(BWsdil), title('dilated gradient mask');
>
> BWdfill = imfill(BWsdil, 'holes');
> figure, imshow(BWdfill);
> title('binary image with filled holes');
> BWnobord = imclearborder(BWdfill, 4);
> figure, imshow(BWnobord), title('cleared border image');
> seD = strel('diamond',1);
> BWfinal = imerode(BWnobord,seD);
> BWfinal = imerode(BWfinal,seD);
> figure, imshow(BWfinal), title('segmented image');
> BWoutline = bwperim(BWfinal);
> Segout = I;
> Segout(BWoutline) = 255;
> figure, imshow(Segout), title('outlined original image');


/////////////////////////////////////////////////////////////////////////

I hope
below code is help to you.
You can test this code foe any other image.

clc;
clear all;
coba1 = imread ('TEST_1.JPG');
figure, imshow (coba1);
if size(coba1,3)==3 %RGB image
j=rgb2gray(coba1);
end
figure, imshow (j);
ved=edge(j,'prewitt');
imshow (ved);
cp=bwareaopen(ved,5);
figure, imshow (cp), title ('after cleaning phase');


se90 = strel('line',5,90);
se0 = strel ('line',5,0);
BWsdil = imdilate(cp, [se90 se0]);
figure, imshow(BWsdil), title('dilated gradient mask');

BWdfill = imfill(BWsdil, 'holes');
figure, imshow(BWdfill);
title('binary image with filled holes');
BWnobord = imclearborder(BWdfill, 4);
figure, imshow(BWnobord), title('cleared border image');
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title('segmented image');
BWoutline = bwperim(BWfinal);
%Segout = I;
Segout(BWoutline) = 255;
figure, imshow(Segout), title('outlined original image');



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.