fiji / Trainable_Segmentation

Fiji library to perform image segmentation based on the Weka learning schemes
https://imagej.net/Trainable_Weka_Segmentation
GNU General Public License v3.0
106 stars 60 forks source link

Weka Segmentation Class Colors #72

Closed julien2424 closed 2 years ago

julien2424 commented 2 years ago

Hello!

We are using Weka Segmentation in a Java application to segment an image and would like to understand how class colors are chosen. When we segment the below image, we get this output after running Weka Segmentation (Class 1 is white, Class 2 is Black, Class 3 is Grey). The output image I get is different than what I get if I run the same process in FIJI so let me know if I'm doing something wrong.

Original: original

Output: test_result

Code:

final ImagePlus imp= new ImagePlus(originalFilepath);
WekaSegmentation original = new WekaSegmentation(imp);
// call method to set class labels
// call method to set examples for 3 classes
original.trainClassifier();
original.applyClassifier( true );
ImagePlus result = original.getClassifiedImage();

We need to understand which classes will be what colors, or how we can choose a class's color before segmenting as we will need to threshold the image for the different classes. For example, if we have 4 classes, what will the color of each class be, and what about for 5 classes?

Let me know if you need me to explain or clarify anything. Thanks!

frett27 commented 2 years ago

Are the images the same resolution in both cases ?

Le mer. 9 mars 2022 à 19:18, julien2424 @.***> a écrit :

Hello!

We are using Weka Segmentation in a Java application to segment an image and would like to understand how class colors are chosen. When we segment the below image, we get this output after running Weka Segmentation (Class 1 is white, Class 2 is Black, Class 3 is Grey). The output image I get is different than what I get if I run the same process in FIJI so let me know if I'm doing something wrong.

Original: [image: original] https://user-images.githubusercontent.com/43152798/157504630-7dd4ba36-5ce1-4419-a96b-a64b9187d0e9.PNG

Output: [image: test_result] https://user-images.githubusercontent.com/43152798/157504679-a2dcb145-68fd-4b13-a555-a810a47a4d8d.jpg

Code:

final ImagePlus imp= new ImagePlus(originalFilepath); WekaSegmentation original = new WekaSegmentation(imp); // call method to set class labels // call method to set examples for 3 classes original.trainClassifier(); original.applyClassifier( true ); ImagePlus result = original.getClassifiedImage();

We need to understand which classes will be what colors, or how we can choose a class's color before segmenting as we will need to threshold the image for the different classes. For example, if we have 4 classes, what will the color of each class be, and what about for 5 classes?

Let me know if you need me to explain or clarify anything. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/fiji/Trainable_Segmentation/issues/72, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5FV32RA75QGW3CDTUHFQLU7DTQJANCNFSM5QKKTMTQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

julien2424 commented 2 years ago

@frett27 My input image is 24-bit color and both FIJI and my code return 8-bit color images. All images have the same resolution. This is the image from FIJI for reference: Classified image fiji

julien2424 commented 2 years ago

@frett27 After looking at it more, I was able to get my code to return the same image FIJI does (like the image above), but I would still like to know how I could set the colors for different classes. Is this possible?

frett27 commented 2 years ago

My usage was only binary for classification, so i did not had to interpret result, none the less, have you tried activate the probability map ?

on the wekasegmentation code

public ImagePlus applyClassifier( final ImagePlus imp, int numThreads, final boolean probabilityMaps)

it seems to create an hyperstack for getting all the classes independently

Le jeu. 10 mars 2022 à 23:09, julien2424 @.***> a écrit :

@frett27 https://github.com/frett27 After looking at it more, I was able to get my code to return the same image FIJI does (like the image above), but I would still like to know how I could set the colors for different classes. Is this possible?

— Reply to this email directly, view it on GitHub https://github.com/fiji/Trainable_Segmentation/issues/72#issuecomment-1064552898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5FV35B3QLFMHJ2NNU5NXTU7JXI7ANCNFSM5QKKTMTQ . You are receiving this because you were mentioned.Message ID: @.***>