Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
edge extraction

Subject: edge extraction

From: Toan Cao

Date: 26 Feb, 2011 02:07:24

Message: 1 of 7

Hello everyone,
i have a gray image: http://i51.tinypic.com/55lawo.jpg
i would like to extract this image into 2 binary images: one image has only vertical lines, another one has only horizontal lines.
i try to do by using some morphological operators, but result is so bad because the brightness of lines and background is almost the same.
i hope everyone will recommend for me some methods to implement better.
Looking forward to your reply
Thanks in advance,
Toan

Subject: edge extraction

From: ImageAnalyst

Date: 26 Feb, 2011 02:44:58

Message: 2 of 7

I'd try adapthisteq() on it. This does contrast limited adaptive
histogram equalization (CLAHE). I'd try it myself but your web site
won't let me download the actual jpg version of your image.

Subject: edge extraction

From: ImageAnalyst

Date: 26 Feb, 2011 03:09:11

Message: 3 of 7

On Feb 25, 9:44 pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> I'd try adapthisteq() on it.  This does contrast limited adaptive
> histogram equalization (CLAHE).  I'd try it myself but your web site
> won't let me download the actual jpg version of your image.

--------------------------------------
This code should get you started. I'm not sure the clahe is really
needed though if we do the filtering with the [1 -1] filter - you
could check. It looks like you want to do barrel distortion
correction, so you might actually want to find crossing points and
then use maketform() and tformfwd(). For true barrel distortion (a
first order optical aberration), the displacement is proportional to
the cube of the radius of the point from the optic axis.

displacement = (r_bad - r_perfect) = constant * r_perfect

bwmorph has an option to find crossing points once you get the binary
image by thresholding your filtered image.

Anyway, here's the code for you to tweak.

% IMPORTANT: The newsreader may break long lines into multiple lines.
% Be sure to join any long lines that got split into multiple single
lines.
% These can be found by the red lines on the left side of your
% text editor, which indicate syntax errors, or else just run the
% code and it will stop at the split lines with an error.
% function test1
clc;
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;

% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end

% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image
Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end

% Read in a standard MATLAB color demo image.
folder = 'C:\Documents and Settings\tk2013\My Documents\Temporary stuff
\';
baseFileName = 'grid.png';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Convert to monochrome right away.
grayImage = rgb2gray(rgbImage);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original image.
subplot(2, 3, 1);
imshow(grayImage, []);
title('Original color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));

% Try clahe on it.
equalizedImage = adapthisteq(grayImage, 'NumTiles', [8 8]);
% Display the image.
subplot(2, 3, 2);
imshow(equalizedImage, []);
title('Histogram Equalized Image', 'FontSize', fontSize);

% Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(equalizedImage);
subplot(2, 3, 3);
bar(pixelCount);
title('Histogram of clahe image');
xlim([0 grayLevels(end)]); % Scale x axis manually.

kernel = [1 -1];
edgeImageV = imfilter(equalizedImage, kernel);
% Display the image.
subplot(2, 3, 4);
imshow(edgeImageV, []);
title('VerticalEdge Image', 'FontSize', fontSize);

kernel = [1 -1]';
edgeImageH = imfilter(equalizedImage, kernel);
% Display the image.
subplot(2, 3, 5);
imshow(edgeImageH, []);
title('Horizontal Edge Image', 'FontSize', fontSize);

Subject: edge extraction

From: karoot RAZA

Date: 26 Feb, 2011 03:23:23

Message: 4 of 7

Voice activity detection using zero crossing rate
i m doing VAD based on zero crossing rate.i have studied papers and come to know that zero crossing rate threshold is


ZCRT=mean(noise)+5*standard deviation(noise)


how can i set value of detection?how can i implement ZCR in SIMULINK?
is there any other method?

Subject: edge extraction

From: ImageAnalyst

Date: 26 Feb, 2011 03:43:03

Message: 5 of 7

On Feb 25, 10:23 pm, "karoot RAZA" <commando...@hotmail.com> wrote:
> Voice activity detection using zero crossing rate
> i m doing VAD based on zero crossing rate.i have studied papers and come to know that zero crossing rate threshold is
>
> ZCRT=mean(noise)+5*standard deviation(noise)
>
> how can i set value of detection?how can i implement ZCR in SIMULINK?
> is there any other method?

---------------------------------------
Uh, I think you replied to the wrong thread.

Subject: edge extraction

From: karoot RAZA

Date: 28 Feb, 2011 06:56:04

Message: 6 of 7

oh sorry for that.



but can u help me regarding this?

Subject: edge extraction

From: ImageAnalyst

Date: 28 Feb, 2011 10:23:33

Message: 7 of 7

On Feb 28, 1:56 am, "karoot RAZA" <commando...@hotmail.com> wrote:
> oh sorry for that.
>
> but can u help me regarding this?

-------------------------------------------------------
No. Others might though, if you begin a new thread with an
appropriate subject line.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us