Creating 2D geometric shapes?

조회 수: 6 (최근 30일)
Jason
Jason 2011년 6월 22일
Hi, I need help here.
Basically, I am experimenting with this function called Hu Invariant Moment, starting off with a few geometric shapes (square, circle, triangle) created using (Windows) Paint. Those images were rotated, translated and scaled accordingly but for some strange reasons, when I saved those pictures, they didn't come out perfectly for me. What I meant by perfect was that I was expecting very thin contour lines (single pixel) for all the images, but that was not the case. By the way, the shapes are on white backgrounds.
So, is it possible to use MATLAB to create/draw out those shapes with the outlines as thin as possible?
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2011년 6월 22일
Can you post the images somewhere so we can see them?
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Jason
Jason 2011년 6월 22일
Hi Sean, thank you for you post. This is the results that I got when I run the code. Note: First image of each row is the original image, followed by the translated, rotated and scaled ones respectively.
http://www.flickr.com/photos/jokerzy89/5859633359/in/photostream

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

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 22일
I would guess the image actually isn't losing information, you're just zoomed out enough that it's not displaying everything (computer pixel resolution). Zoom in on one of the subplots and see if it looks better close up.
edit from comments
I = imread('ans622.jpg'); %your image
imshow(I(:,:,1),[0 1]); That's your original image - and hence why you're seeing the skeleton the way it is.
so what you want is
Ibw =(I(:,:,1)>200); %red channel greater than 200;
imtool(Ibw); %already 1px thick but you could run bwmorph for good measure or fun.
  댓글 수: 15
Sean de Wolski
Sean de Wolski 2011년 6월 22일
because the other values are not visible due to the range that imshow is displaying. That's why I try to avoid it and use imtool. imtool offers you the adjust contrast tool on a visible histogram so you can see where/what values are and adjust the settings to make them visible.
(the little half white half black circle in imtool)
Jason
Jason 2011년 6월 22일
Awesome, thank you once again!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by