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

2 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2012-6-1
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 个评论
Elad
Elad 2012-6-2
out of curiosity, how did you choose the blue plane and the value 163 for the treshold ?
Image Analyst
Image Analyst 2012-6-2
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.

请先登录,再进行评论。

更多回答(1 个)

Elad
Elad 2012-6-1
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.

类别

Help CenterFile Exchange 中查找有关 Ceramics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by