Message Boards Message Boards

2 Replies
0 Total Likes
View groups...
Share this post:

Select 2 clusters in image. MatrixPlot and Colorize

Posted 9 years ago

I want to separate 2 clusters in image. First cluster should be white, second should be black. I have two questions:

  1. When I use MatrixPlot function, I found some orange pixels. Why I have been found them? There are only 2 clusters: 1 - black, 2 - white. More you can see on the photo. Code is there

    file = Import["D:\\Mathematica\\0.jpg"];
    dataImage = ImageData[file];
    listClust = ClusteringComponents[dataImage, 2, 2];
    MatrixPlot[listClust, ColorRules -> {1 -> White, 2 -> Black}]
  2. How can I drow Image without using MatrixPlot. I have tryed something like this

    image2Clusters = Image[listClast];
     image3Clusters = Image[newClustersList];

but there are only blue background. Nothing else.

POSTED BY: Dmitry Dmitriev
2 Replies

Can you post original image? We do not have your "D:\" drive ;-)

POSTED BY: Sam Carrettie

Could you run Union@Flatten@listClust just to make sure there are only 1s and 2s in the output? Also, try ArrayPlot[listClust, ColorRules -> {1 -> White, 2 -> Black}].

POSTED BY: Jesse Friedman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract