Creating code that will recognize colors on a plot.

2 次查看(过去 30 天)
I am trying to create a code that will register when there is no longer any white pixles and stop. I'm not sure if there is a function in matlab to scan a plot for a particular color but that is what I am looking for. Basically I would like to have it set up so that if it finds white on the plot nothing happens but once it no longer finds white it will increase a variable by 1.
  2 个评论
Dyuman Joshi
Dyuman Joshi 2023-11-29
Though I'm not sure what exactly you want to do, but one approach can be to save the plot as an image via exportgraphics, and scan the image accordingly.
Do you want get the number of non-white pixels in an image?
DGM
DGM 2023-11-29
编辑:DGM 2023-11-29
You've given a problem description which is simultaneously vague and seemingly contradictory. You have provided no concrete examples of the input image, nor have you even provided enough information to determine whether the input is a raster image at all. If you're trying to count pixels in an image of a plot, then I highly doubt that counting pixels is anything other than an XY problem, as the scale of exported figures is (effectively) arbitrary.
  • Explain the purpose of the exercise.
  • Provide an example of the expected input.
  • Provide an example of the expected output.
Try to make sure the things you write make sense to other people who can't read your mind.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2023-11-29
Simply use the Color Thresholder on the Apps tab of the tool ribbon. Use HSV or LAB color space. Adjust the sliders to segment out what you consider "white" to be. Then tell it to export the function. You'll get a mask of white pixels. To get a mask of non-white pixels, simply invert the mask. Or you can adjust the sliders to give you non-white pixels right away.

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by