Message Boards Message Boards

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

Select 2 clusters in image. MatrixPlot and Colorize

Posted 10 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];
     Colorize[image2Clusters]
     Colorize[image3Clusters]
    

but there are only blue background. Nothing else.

Attachments:
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
Attachments
Remove
or Discard

Group Abstract Group Abstract