High Resolution Image Segmentation of small features in grey Microstructure (BSE) image

I think there is some simple method to solve it. such as dog and region analysis to filter the small region, and detect the edge, to check if it locates on edge.

How would you do that?

In principle, this can also be done in ilastik by

  1. do pixel classification for foreground/background segmentation. Here I would make sure to segment the objects your are interested in (foreground) as good as possible, not worrying too much about false positives in the background (those can be dealt with in the second step):
  2. take the resulting probability map (ilastik shows probability maps per default) and go to object classification. (You might need to work on a cutout of your image there first for training, depending on how much ram you have). In thresholding select the foreground channel and maybe play around a bit with the threshold value (also the size filter might be interesting for you). But the real powerful thing you can do is train a classifier based on object features in the next step (as opposed to pixel classification, where features are only computed per pixel). This allows the random forest to “see” features describing the size, shape, histogram … and many others to the individual objects.
1 Like

Thank you very much for the insight :slight_smile: I never really got the difference between pixel classification and object classification before.

1 Like

Even with hdf5 on a 64GB pc I get a "memoryerror" when I try to do object classification on a 10000*10000 pixel image. Even though the RAM taken is max. 20GB.

Can’t I add objects to labels in blockwise object classification? Selection classification for a few labels at once and doing a blockwise object classification works much quicker than “live update” for me but switching back and forth to the regular “object classification” is quite tedious… especially because the field of view keeps changing. Any way to combine both?

ERROR 2019-03-07 08:12:35,023 excepthooks 7628 7412 Traceback (most recent call last):

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\tiling.py", line 773, in _fetch_tile_layer

img = ims_req.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\imagesources.py", line 387, in wait

return self.toImage()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\imagesources.py", line 393, in toImage

self._arrayreq.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\slicesources.py", line 46, in wait

return self._sp(self._ar.wait())

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\datasources.py", line 473, in wait

rawData = self._rawRequest.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\datasources.py", line 204, in wrapper

return func(*args, **kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\volumina\volumina\pixelpipeline\datasources.py", line 228, in wait

a = self._req.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opReorderAxes.py", line 160, in execute

self.Input( *in_roi ).writeInto( result_input_view ).wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 793, in call

return self.func( *totalargs, **self.kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opUnblockedArrayCache.py", line 83, in execute

self._execute_Output(slot, subindex, roi, result)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opSimpleBlockedArrayCache.py", line 100, in _execute_Output

pool.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 1313, in wait

self._clear_finishing_requests()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 1390, in _clear_finishing_requests

req.block()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 506, in block

self._wait(timeout) # No return value. Use wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 609, in _wait_within_request

raise_with_traceback(exc_type(exc_value), exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opSimpleBlockedArrayCache.py", line 87, in copy_block

self._execute_Output_impl( full_block_roi, full_block_data )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opUnblockedArrayCache.py", line 108, in _execute_Output_impl

self._fetch_and_store_block(request_roi, out=result)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opUnblockedArrayCache.py", line 146, in _fetch_and_store_block

block_data = req.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 793, in call

return self.func( *totalargs, **self.kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opCacheFixer.py", line 63, in execute

self.Input(roi.start, roi.stop).writeInto(result).wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 793, in call

return self.func( *totalargs, **self.kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opReorderAxes.py", line 160, in execute

self.Input( *in_roi ).writeInto( result_input_view ).wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 793, in call

return self.func( *totalargs, **self.kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\operators\opFilterLabels.py", line 55, in execute

req.wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 793, in call

return self.func( *totalargs, **self.kwargs)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 887, in call

result_op = self.operator.execute(self.slot, (), self.roi, destination)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\thresholdTwoLevels\opThresholdTwoLevels.py", line 263, in execute

self.execute_funcs[self.Method.value](t_slice_roi, result_slice)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\ilastik\ilastik\applets\thresholdTwoLevels\opThresholdTwoLevels.py", line 271, in _execute_SIMPLE

data = self.Input(roi.start, roi.stop).wait()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 500, in wait

return self._wait(timeout)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 526, in _wait

self._wait_within_request( current_request )

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 651, in _wait_within_request

raise_with_traceback(exc_value, exc_tb)

File "C:\Program Files\ilastik-1.3.2\lib\site-packages\future\utils_init_.py", line 421, in raise_with_traceback

raise exc.with_traceback(traceback)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\request\request.py", line 324, in _execute

self._result = self.fn()

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\slot.py", line 872, in call

destination = self.slot.stype.allocateDestination(self.roi)

File "C:\Program Files\ilastik-1.3.2\ilastik-meta\lazyflow\lazyflow\stype.py", line 112, in allocateDestination

storage = numpy.ndarray(shape, dtype=self.slot.meta.dtype)

MemoryError

this is indeed a limitation of object classification - it will access the whole dataset (and yours is quite big). The only way around it is to train on a smaller cutout and process the whole dataset headless in block-wise object classification. There your image is processed in smaller blocks.

Configuration:

  • block size: block-size that is processed individually
  • halo size: extra area around the block to take into account (should be the maximum size of the objects you expect in order to achieve consistent results and not get blocking artifacts)

You’ll have to choose blockwise prediction as an output.

2 Likes

I know it is a bit late to address this, but what is the amount of RAM you have allocated for Fiji? From your image, it looks like it stops at around 16 GB. I have definitely opened larger images; even with the native I/O.