Can we count the color pixels in each box like it did in mathematica?

1 view (last 30 days)
I am working in a project to split an image into small boxes of equal size which I have made. The problem is that when OI concatinate the boxes again to count the number of color pixels and use it for further computation then there are many new colors of which I dont know the name and it coounted to be about more than 17000 in an 1000 x 1000 image. I splitted an imae in mathematica and ploted the number of color pixels with their shade that made my work quite easy but the porblem is that when I work for larger box number it keep on running and very slow computation as compared to matlab. I want to do that in matlab to reduce the computaional cost. Kindly help.
This is what mathematica gives me for a 25 x 25 image when it is splitted into 5 x 5 boxes and each box contained 25 pixels.
  3 Comments
Mario Malic
Mario Malic on 16 Sep 2020
Edited: Mario Malic on 16 Sep 2020
"This is what mathematica gives me for a 25 x 25 image when it is splitted into 5 x 5 boxes and each box contained 25 pixels."
From the image and this information from the post, it's possible to deduce that all pixels are in the each box. Adam, I am impressed by the amount of work you invested in that just-for-fun post (+1 on that).
Regarding the computational cost, I doubt it's that big, even though it's 3 milion elements (1000x1000x3) that should be analysed. The thing is that, if image you're analysing is a colorful image, then think about how can you display all the colors in the box, you'll have to set some threshold on count of colors.
About the process, load the image and split the image array according to the sizes, and set up the process for 1 box and just loop it for remaining boxes.
Adam Danz
Adam Danz on 16 Sep 2020
Thanks, Mario.
@Atique Khan , on second glance, it looks like the Mathematica algorithm is also not differentiating between very similar but numerically different colors so I can't imagine what it's doing.

Sign in to comment.

Answers (0)

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!