How do i find edges in true colored image
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I need to extract red plane of true color image. Then need to apply 8 directions sobel mask on this red plane image. then need to perform sobel edge detection using threshold value.
This is need to repeat for blue and green plane image as well
Can anyone please guide me how can i do that in matlab.
I am able to extract true red plane image by keeping blue and green as 0.But inbut filter2 function doesnt work on this.
Respuestas (2)
Image Analyst
el 24 de Mayo de 2012
This ought to give you a good start:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
workspace; % Make sure the workspace panel is showing.
fontSize = 14;
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.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);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 4, 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);
% Display them
subplot(2,4,2);
imshow(redChannel);
title('Red Channel', 'FontSize', fontSize);
subplot(2,4,3);
imshow(greenChannel);
title('Green Channel', 'FontSize', fontSize);
subplot(2,4,4);
imshow(blueChannel);
title('Blue Channel', 'FontSize', fontSize);
% Compute Sobel Filters and threshold them
threshRed = 1;
threshGreen = 3;
threshBlue = 4;
[sobelRed threshRed] = edge(redChannel,'sobel');
[sobelGreen threshGreen] = edge(greenChannel,'sobel');
[sobelBlue threshBlue] = edge(blueChannel,'sobel');
% Display them
subplot(2,4,6);
imshow(sobelRed, []);
title('Sobel Filter on Red Channel', 'FontSize', fontSize);
subplot(2,4,7);
imshow(sobelGreen, []);
title('Sobel Filter on Green Channel', 'FontSize', fontSize);
subplot(2,4,8);
imshow(sobelBlue, []);
title('Sobel Filter on Blue Channel', 'FontSize', fontSize);
4 comentarios
Image Analyst
el 25 de Mayo de 2012
uint8's clip when they go beyond 255. Cast to double before you add:
t3=(double(ta1)+double(ta2)+double(ta3)+double(ta4)+double(ta5)+double(ta6)+double(ta7)+double(ta8));
figure,imshow(t3, []); % Make sure you use [] to properly scale.
ankita taparia
el 10 de Dic. de 2018
Why have we done thresholding here? And if i want to apply a 3x3 sobel filter then what change is to be done in the code?
0 comentarios
Ver también
Categorías
Más información sobre Blue en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!