Hi
I would like to generate a simple mask image from scratch in Matlab if it is possible.
It has the following criteria:
  1. the size of the image needs to be 500 x 500 pixels.
  2. the center of the mask image needs to be a number, say 8. This area is white [255 255 255].
  3. the size of the number is best to be adjustable by fontsize?.
  4. the rest of the areas in the mask image needs to be black [0 0 0].
See the sample image below which is NOT done in Matlab. Is this achievable in Matlab?

 채택된 답변

Image Analyst
Image Analyst 2022년 10월 3일
편집: Image Analyst 2022년 10월 3일

0 개 추천

It's a trivial modification of the code in the FAQ that draws a ring. Just make two rings with different centers and radii.
You could also use insertText if you have the Computer Vision Toolbox.

댓글 수: 5

Salad Box
Salad Box 2022년 10월 4일
Thank you for your answer. I am not exactly sure whether this is what I need though.
Image Analyst
Image Analyst 2022년 10월 4일
Well you accepted your own answer where you used my suggestion of using insertText. So why was my answer not what you needed?
And you originally posted an 8 which looked like two rings which can be created from the FAQ code if you didn't have the Computer Vision Toolbox. This would have worked for the 8.
So I feel like I gave you what you needed. Since you accepted your own answer can you at least click the "Vote" icon for mine (it awards me "reputation points")? Thanks in advance. 🙂
Salad Box
Salad Box 2022년 10월 4일
I accepted your answer. Thank you for your contribution. I realized that my answer is not perfect. When I double the size, the image is not pure black and white no more but with some noise. I need to fix that I think.
Image Analyst
Image Analyst 2022년 10월 4일
Thanks. You can use imbinarize to force it to have no "noise" or gray levels, which are probably used to anti-alias (smooth) the character. Also, if you save the image(s) make sure you use the PNG extension, for lossless compression, rather than JPG which will change and add gray levels due to it being lossy compression.
Salad Box
Salad Box 2022년 10월 4일
Thank you very much for your advices. I will try the imbinarize.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tracking and Motion Estimation에 대해 자세히 알아보기

태그

질문:

2022년 10월 3일

댓글:

2022년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by