Info
此问题已关闭。 请重新打开它进行编辑或回答。
I would appreciate some assistance on some coding.
1 次查看(过去 30 天)
显示 更早的评论
The goal is to create this image:
It is a 2-dimensional array made of ones (size 100x100), and I need to set up a single 'for' loop with 100 iterations from row 1 to row 100, applying conditional statements inside the loop to generate the binary image.
There may be various ways to go by achieving my goal, the path I have chosen consists of me gathering all the points, and thus filling in the points.
Image below to show my progress:
So this led me to think of two questions. 1) Is it even possible for me to "fill" the points, and 2) Is there a better way to do this, and if so, could anyone supply me with the neccesary coding required?
Thanks. (p.s, this is being done on R2019A, but R2019B works just fine too)
2 个评论
Steven Lord
2019-11-22
Can you show us the code you've written to try to solve the problem and describe the specific difficulty or difficulties you're having? If you do we may be able to provide some guidance and/or feedback on your code.
回答(1 个)
Image Analyst
2019-11-22
If you have the vertex points, create the binary image
binaryImage = false(100, 100);
Then use poly2mask(x, y, 100, 100) to create binary images that you OR in with the first one.
oneRegion = poly2mask(x, y, 100, 100);
binaryImage = binaryImage | oneRegion;
Repeat for every closed square or triangular region using the x and y coordinates of that particular region.
6 个评论
Image Analyst
2019-11-23
Nothing that I have that is all ready to go and ready to hand over to you. I'd have to go through the same tedious exercise as you would, so I'll just leave that to you.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!