Optimization of Training: Balance between number of labels in Pixel & Object Classification

Dear forum members.

I want to segment backscattered electron images from a metal surface. Due to limited computing power I split my 30k x 20k pixel images into (5x5=) 25 6k x 4k pixel images.

I need to segment small white precipitates
and classifiy them according to three different categories
round and white with black in center = titanium
round and white = carbide
elongated (at grain boundary) = delta

examples

and in some areas I have some artifacts from sample preparation that I cannot get rid of completely:

If I got it right I should do:
pixel classification into background and precipitate
and
object classification into titanium, carbide or delta precipitate

whats the best workflow to exclude false positives like scratches/dirt/white areas in the background?
should I add an “artifact” label in pixel classification or rather sort things out in object classification?

How to best decide which level of sorting/false positives is okay in pixel classification and as good as I can get in object classification?

Is there a way to Export labels in object classification and import them to the object classification of another image (just like its possible to reuse labels in pixel classification)?

Thanks

Hi @Sebban,

as far as I see it you have figured it out already. Yes, add an artifact class and you are ready to go. Visually it doesn’t look so challenging. As for the false positives, I do not really have a good answer for this. I can imagine that it is not possible to remove all artifacts in Pixel Classification. But it looks like their shape and the appearance of the surrounding should be different enough for Object classification.

there is a way, but it is only available in debug (starting ilastik with the --debug command line argument) mode and relies on the segmentation being the same. It is available via the “Export” menu item. But be warned - in debug mode it is easier to do something that is not really intended - ilastik might behave more unstable.

already in pixel classification or rather in object classification?

adding --debug to the shortcut properties in Windows works thanks I’ll give it a try

How can I export my finished “object prediction” as coloured jpeg/tif?
If I got it right the .h5 export will automatically assign number labels and then I import the picture in imagej and apply Image :arrow_forward: Lookup Tables for a color scheme of choice?

yup, that’s the way to go. If you want something to look at from your exported .h5 files (and you have many of those) then this is also easily scriptable with e.g. Python

in Object classification it will be way easier. And this is what Object Classification was designed for.

On a side note you might also be able to achieve a better pixel classification using the autocontext workflow as it takes into account for each pixel and the semantic information of the first stage and implicitly a larger field of view. I gave it a quick go with three labels in the first stage (shiny spot like thingies, scratch and background) and two in the second stage (background, shiny spot like thingies) and it sort of worked:

either this or opening a command prompt and navigating to your windows installation (something like "C:\Program Files\ilastik-1.3.2post1"):

cd "C:\Program Files\ilastik-1.3.2post1"
ilastik.exe --debug
1 Like

I have exported the object classification labels.

How can I import trained object classification to a new picture in debug mode? So that I don’t have to retrain object classification in every picture.

I cant find the “import” option.


I will give autocontext workflow a try. thanks

Hey I think I have misunderstood you. Now I don’t think that the debug option is what you want anymore. So you want to apply your trained classifier on new, unseen images?

Yes I know how to do this in pixel classification but not how it can be done in object classification.

this is basically the same scheme. You’ll first have to process your image with your trained pixel classification project to generate a probability map. With this probability map and the raw image you can apply your object classification project either via the batch processing applet or in headless mode.

Let me know if you need any help setting those up

Okay but importing the object classification labels for retraining on the new image is not possible?
My plan was to correct object classification by hand for a few more pictures before switching to batch processing.

you can achieve this by adding the image (and it’s probability map) as a new lane to your existing project (via the input data applet). You can then train your classifier using annotations from all images you are adding this way. But we do not recommend to add more than ten images at the moment, as it gets slow :slight_smile:

1 Like

Okay got the idea, I’ll see what I can get