WOW !! MUCH LOVE ! SO WORLD PEACE !
Fond bitcoin pour l'amélioration du site: 1memzGeKS7CB3ECNkzSn2qHwxU6NZoJ8o
  Dogecoin (tips/pourboires): DCLoo9Dd4qECqpMLurdgGnaoqbftj16Nvp


Home | Publier un mémoire | Une page au hasard

 > 

Implementation of edge detection for a digital image

( Télécharger le fichier original )
par Innocent MBARUBUKEYE
KIST - AO Electronics and telecommunication engineering 2008
  

précédent sommaire suivant

Bitcoin is a swarm of cyber hornets serving the goddess of wisdom, feeding on the fire of truth, exponentially growing ever smarter, faster, and stronger behind a wall of encrypted energy

3.5. IMPLEMENTATION OF EDGE DETECTION.

I n this section, implementation was based on two different operators such as:

Sobel operators and Prewitt operators. These two operators are used in writing program, which were basically used in processing of digital images. Here is the whole program:

Writeable commands

Results obtained.

I=imread('dushime.jpg');

figure, imshow(I), title('original image');

 

rgb2gray('dushime.jpg');

newmap=rgb2gray(I);

figure, imshow(newmap),title('gray image');

 

BWs=edge(newmap, 'sobel', (graythresh(newmap) * .1));

figure, imshow(BWs), title('binary gradient');

 

Se90=strel('line', 3, 90);

Se0=strel('line', 3, 0);

BWsdil=imdilate(BWs, [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('outline original image');

end

 

The above program is used to process the JPEG format while the following program is used to process the BMP format.

I=imread('nouvelle.bmp');

figure, imshow(I), title('original image');

 

rgb2gray('nouvelle.bmp');

newmap=rgb2gray(I);

figure, imshow(newmap),title('gray image');

 

BWs=edge(newmap, 'sobel', (graythresh(newmap) * .1));

figure, imshow(BWs), title('binary gradient');

 

Se90=strel('line', 3, 90);

Se0=strel('line', 3, 0);

BWsdil=imdilate(BWs, [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('outline original image');

end

 

PREWITT OPERATOR (EDGE DETECTOR).

% edge detection with prewitt operator

filename= 'NEW.bmp'; % the filename to be read

image = imread(filename);

Imshow(image); % display

 

rgb2gray('NEW.bmp');

newmap=rgb2gray(image);

figure, imshow(newmap),title('gray image');

 

axis('square');

colormap('gray');

sze=size(newmap);

rows = sze(1); cols = sze(2);

 

% apply prewitt

Prw_im=edge(newmap,'prewitt');

figure(2);

 

imagesc(Prw_im);

axis('square');

colormap('gray');

end

 

EDGE DETECTION WITH SOBEL

% edge detection with Sobel operator program

filename= 'NEw.bmp'; % the filename to be read

image = imread(filename);

figure,Imshow(image),title('original image'); % display

 

rgb2gray('NEW.bmp');

newmap=rgb2gray(image);

figure,imshow(newmap),title('gray image');

 

axis('square');

colormap('gray');

sze=size(newmap);

rows = sze(1); cols = sze(2);

 

% apply sobel

sob_im=edge(newmap,'sobel');

figure(2);

 

imagesc(sob_im);

axis('square');

colormap('gray');

end

 

COMPARISON FOR EDGE DETECTION BETWEEN SOBEL AND PREWITT.

Writeable program

Obtainable result

% comparison for edge detection between Sobel & Prewitt operators.

filename= 'NEW.bmp'; % the filename to be read

image = imread(filename);

figure, Imshow(image), title ('original imge') % display

 

rgb2gray('NEW.bmp');

newmap=rgb2gray(image);

figure, imshow(newmap),title('gray image');

 

axis('square');

colormap('gray');

sze=size(newmap);

rows = sze(1); cols = sze(2);

 

% apply prewitt

sob_im = edge(newmap,'sobel');

figure, imshow(sob_im), title ('sobel image');

Figure 3.5.a. sobel image

prw_im= edge(newmap,'Prewitt');

figure, imshow(prw_im), title('prewitt image');

Figure 3.5.b. prewitt image.

dif_im=double(sob_im)- double(prw_im);

figure(2);

 

imagesc(dif_im);

axis('square');

colormap('gray');

end

 

CHAPTER 4. RESULTS AND DISCUSSION.

précédent sommaire suivant






Bitcoin is a swarm of cyber hornets serving the goddess of wisdom, feeding on the fire of truth, exponentially growing ever smarter, faster, and stronger behind a wall of encrypted energy








"Il y a des temps ou l'on doit dispenser son mépris qu'avec économie à cause du grand nombre de nécessiteux"   Chateaubriand