Improve edge detection of image

15 次查看(过去 30 天)
fatima ali
fatima ali 2014-10-31
编辑: fatima ali 2014-11-11
i need function or code in matlab to Improve and edge detection this image
  2 个评论
Image Analyst
Image Analyst 2014-10-31
What do you need to find? The outline of the whole foot, or the small fine lines and wrinkles within the foot.
per isakson
per isakson 2014-10-31
It's not a good idea to call many questions "welcome please help me". I renamed this one.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2014-10-31
Didn't hear from you so I just guessed.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 24;
%===============================================================================
% Read in a standard MATLAB color demo image.
folder = 'C:\Users\fatima\Documents\Temporary';
baseFileName = 'foot.jpg';
% 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);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
binaryImage = blueChannel < 118;
% Display the original color image.
subplot(2, 2, 2);
imshow(binaryImage);
axis on;
title('Initial Binary Image', 'FontSize', fontSize);
% Clean it up.
% Fill holes.
binaryImage = imfill(binaryImage, 'holes');
% Get rid of small blobs.
binaryImage = bwareaopen(binaryImage, 10000);
% Smooth border
binaryImage = imclose(binaryImage, true(5));
% Display the original color image.
subplot(2, 2, 3);
imshow(binaryImage);
axis on;
title('Cleaned Binary Image', 'FontSize', fontSize);
% Get the boundary and outline it over the original image.
boundaries = bwboundaries(binaryImage);
x = boundaries{1}(:, 2);
y = boundaries{1}(:, 1);
% Display the original color image.
subplot(2, 2, 4);
imshow(rgbImage);
title('Outline over Original Color Image', 'FontSize', fontSize);
% Plot boundaries over it.
hold on;
plot(x, y, 'g-', 'LineWidth', 2);
  14 个评论
fatima ali
fatima ali 2014-11-1
sorry but in this code convert image to binary ...but i need convert image to gray and edge detection
Image Analyst
Image Analyst 2014-11-1
Your edge detection images were binary images. Why is it okay for you to use a binary image to get the outline but I can't? Anyway, who cares if there's a binary image involved as long as you get the outline you want? What difference does it make? It works and that's all that counts.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by