필터 지우기
필터 지우기

Draw 1 inch Square on Image

조회 수: 2 (최근 30일)
Parth Desai
Parth Desai 2018년 9월 12일
댓글: Image Analyst 2018년 9월 12일
Hello,
How can I draw 1 inch square on my image and wanted to find number of grains present in that square ? Attached is my Image for reference. In attached RefImage_WithSquare, wanted to count no. of grains present in that square grains on boundary line must be considered as partial grain. Just as we consider in ASTM Grain Analysis.
  댓글 수: 2
Rik
Rik 2018년 9월 12일
This question is unlikely to get responses for several reasons: you didn't include the image in the first place, any size information is not present (how should pixels be translated to inches), it is unclear what you mean by grains and how they should be counted, and you show nothing about what you already start.
We have nothing to build on, and we have no indication that you care enough to put in some effort. Have a read here (or here for more general advice) and here. It will greatly improve your chances of getting an answer.
You can edit your question to fix these issues, which will automatically re-open your question.
Parth Desai
Parth Desai 2018년 9월 12일
Updated my question with attached images for reference.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 9월 12일
If your resolution is 96 dpi, use the rectangle() function with a width and height of 96:
imshow('untitled.png');
axis on;
hold on;
impixelinfo(); % Show x, y, RGB as you mouse around over image.
xLeft = 85; % Wherever you want.
yTop = 32;
rectangle('Position', [xLeft, yTop, 96, 96], 'EdgeColor', 'r', 'LineWidth', 2);
  댓글 수: 6
Parth Desai
Parth Desai 2018년 9월 12일
Error Undefined function 'yourImage' for input arguments of type 'double'.
Error in Dummy_0 (line 86) subImage = yourImage(yTop:yTop+95, xLeft:xLeft+95);
imshow('Output.png');
axis on;
hold on;
impixelinfo(); % Show x, y, RGB as you mouse around over image.
xLeft = 85; % Wherever you want.
yTop = 32;
rectangle('Position', [xLeft, yTop, 96, 96], 'EdgeColor', 'r', 'LineWidth', 2);
[rows, columns, numColors] = size('Output.png');
if numColors == 3
yourImage = rgb2gray('Output.png');
end
subImage = yourImage(yTop:yTop+95, xLeft:xLeft+95);
binaryImage = subImage ~= 255; % Or whatever color your background is.
% Count blobs and partial blobs.
[labeledImage, numBlobs] = bwlabel(binaryImage);
Image Analyst
Image Analyst 2018년 9월 12일
Parth, you need to read your image into a variable.
Do this:
yourImage = imread('Output.png');
imshow(yourImage);
[rows, columns, numColors] = size(yourImage);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by