Borrar filtros
Borrar filtros

coordinate edge of the ceramic into pixel (x,y)

2 visualizaciones (últimos 30 días)
KURNIAWAN
KURNIAWAN el 30 de Mayo de 2012
i have ceramic images, and how to know coordinate edge of the ceramic into coordinate pixel (x,y) i need coding to find coordinate edge.. pls help

Respuesta aceptada

Image Analyst
Image Analyst el 1 de Jun. de 2012
This would be more accurate if you used a black velvet fabric behind your tile. Then you'd simply threshold and call bwboundaries() or bwperim(). You can still try it with a gray background like you have but your edge may not be as sharp and linear. But try this demo code on your image:
clc;
clearvars;
close all;
workspace;
fontSize = 20;
% Read in a tile color demo image.
folder = 'C:\Users\Kurniawan\Documents';
baseFileName = 'tile.jpg';
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, 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);
subplot(2, 2, 2);
imshow(blueChannel, []);
title('Blue Channel Image', 'FontSize', fontSize);
% Threshold blue channel
binaryImage = blueChannel < 163;
% Get rid of small blobs.
binaryImage = bwareaopen(binaryImage, 10000);
% Fill in any holes in the tile.
binaryImage = imfill(binaryImage, 'holes');
% Display it.
subplot(2, 2, 3);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
% Get the boundary coordinates
tileBoundary = bwboundaries(binaryImage);
% Plot boundaries over original image.
subplot(2, 2, 4);
imshow(rgbImage, []);
title('Original Color Image with Boundary', 'FontSize', fontSize);
hold on;
thisBoundary = tileBoundary{1};
xCoordinates = thisBoundary(:, 2);
yCoordinates = thisBoundary(:, 1);
plot(xCoordinates, yCoordinates, 'b-', 'LineWidth', 3);
  2 comentarios
Elad
Elad el 2 de Jun. de 2012
out of curiosity, how did you choose the blue plane and the value 163 for the treshold ?
Image Analyst
Image Analyst el 2 de Jun. de 2012
I knew it would be the blue plane because the tile was reddish. So the red signal would be high, like the white background, while the red signal would be low, much darker than the white background. Thus the blue channel would give the most contrast. I used my thresholding app in the File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 to determine the threshold. Of course you could also have done that with Photoshop, or just display the histogram of the blue channel in MATLAB and look at it to see the two histogram humps and what gray level you need to use to split them apart.

Iniciar sesión para comentar.

Más respuestas (1)

Elad
Elad el 1 de Jun. de 2012
try this .. a=imread() ; a=rgb2ycbcr(a); a=a(:,:,2); a=edge(a,'canny',[0.1 0.5],15); you can get the coordinates using find() for ones.

Categorías

Más información sobre Ceramics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by