이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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
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
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
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
Jason
2011년 6월 22일
Yes, that's what I did just now, zooming in to inspect the pixels, my guess is that nothing was lost. However, I feel that the lines are quite thick and thus not suitable for Moments calculation, any idea on how to thin those lines? FFT was proposed by my lecturer but I am not really cognizant of the process.
Here's the zoomed in pictures.
http://www.mathworks.com/matlabcentral/answers/10022-creating-2d-geometric-shapes
Note that for the last 2 pictures, around the vicinity of the lines, there are some greyish pixels, do I need to perform thresholding to get rid of those? Basically, I need pictures of type logical (0s and 1s).
Jason
2011년 6월 22일
Sorry here's the correct link: http://www.flickr.com/photos/jokerzy89/5860227992/sizes/l/in/photostream/
Sean de Wolski
2011년 6월 22일
Yes, you can convert it to logical by using a threshold:
Ibw = I>some_value
or if you want anything non-black to show uo
Ibw = logical(I);
to thin the lines look at the 'skel' and 'thin' options in bwmorph. Can you give a little more information or a link for H.I.M.?
Jason
2011년 6월 22일
Thanks again, Sean.
Here's the link to H.I.M: http://en.wikipedia.org/wiki/Image_moment#Rotation_invariant_moments
So, I have got the M-Files for the functions ready. Since black = 0 and white = 1 for images(shapes) of type logical, when I read those images and run the HIM codes to calculate the respective moments, it should give me some values (contributed by the 1s from the lines). I feel that if the lines are not consistent in thickness, this would affect the results.
Sean de Wolski
2011년 6월 22일
It probably would. So use:
I1px = bwmorph(Ibw,'skel',inf); %make the lines one pixel thick.
Jason
2011년 6월 22일
Sean, here's the outcome. Using the code you suggested right above, this is what I got. http://www.flickr.com/photos/jokerzy89/5860309284/sizes/l/in/photostream/
Sean de Wolski
2011년 6월 22일
Huh? Did you binarize it so it was a logical image first?
I1px = bwmorph(logical(I),'skel',inf);
what does imtool(logical(I)) show?
Jason
2011년 6월 22일
Yes, I did, let's name the original image xyz.
I used xyz = logical(xyz), then I1px = bwmorph(xyz,'skel',inf), and got the results as shown on the link above.
In fact, imtool(logical(xyz)) yielded the same outcome.
http://www.flickr.com/photos/jokerzy89/5860401806/sizes/l/in/photostream/
Sean de Wolski
2011년 6월 22일
can you post xyz before the logical operation by itself (a jpg file maybe)
Jason
2011년 6월 22일
http://www.flickr.com/photos/jokerzy89/5860423042/sizes/m/in/photostream/
In case you wish to download the file, just right click on the save it to your PC. Thanks!
Jason
2011년 6월 22일
Sean, if you don't mind, I still cannot see the difference between imshow(I); and imshow(I(:, :, 1),[0 1]);. I thought both should give the same output?
Sean de Wolski
2011년 6월 22일
Save the image from the internet as I have done. Then read it in using imread.
Jason
2011년 6월 22일
I understand, but I am just curious as to why both commands display different output. When I used imshow(I);, I got a square which looks 'perfect', how come there was no skeleton?
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
2011년 6월 22일
Awesome, thank you once again!
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
