LOCAL THRESHOLD AND BOOLEAN FUNCTION BASED EDGE DETECTION

4 ビュー (過去 30 日間)
tarun
tarun 2013 年 5 月 9 日
コメント済み: Image Analyst 2016 年 5 月 14 日
I have to write a matlab code to implement the above edge detection scheme.
Can someone please give me an idea how to start coding it? how should I proceed ?
Below is the brief theory.
Localization of edges is done by this method. The concept behind it is to threshold a gray level image using local mean to make a binary image. It recognizes nearly all-actual edges and edges due to noise. To remove noise edges another approach is used.
I would appreciate any help.

採用された回答

Image Analyst
Image Analyst 2013 年 5 月 9 日
See my demo. Feel free to adapt it as needed.
clc;
clearvars;
close all;
workspace;
fontSize = 16;
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
button = menu('Use which demo image?', 'CameraMan', 'Moon', 'Eight', 'Coins', 'Pout');
if button == 1
baseFileName = 'cameraman.tif';
elseif button == 2
baseFileName = 'moon.tif';
elseif button == 3
baseFileName = 'eight.tif';
elseif button == 4
baseFileName = 'coins.png';
else
baseFileName = 'pout.tif';
end
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- 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 in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
axis on;
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Get the local mean and subtract the original from it
% This is the Laplacian
edgeImage = conv2(double(grayImage), [-1, -1, -1; -1, 8, -1; -1, -1, -1]/8, 'same');
% Display the image.
subplot(2, 2, 2);
imshow(edgeImage, []);
title('Edge Image', 'FontSize', fontSize);
% Let's compute and display the histogram.
[pixelCount, grayLevels] = hist(edgeImage(:), 100);
subplot(2, 2, 3);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of edge image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Threshold the image.
binaryImage = edgeImage > 10;
% Display the image.
subplot(2, 2, 4);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
  3 件のコメント
hani alsareti
hani alsareti 2016 年 5 月 14 日
what is the best way to detect different coins of different countries ? i do have mini project about that
Image Analyst
Image Analyst 2016 年 5 月 14 日
hani, you'd have to create a feature vector consisting of things like the color, mean texture, circularity, area, etc. Then you could use a classifier like treebagger to determine the coin, or just do it manually with a bunch of if/else statements.
Or maybe you could use the cascade detector in the Computer Vision System Toolbox.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Volumetric Image Processing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by