現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
