Separate touching objects and export images individually

Hi everyone,
I got an big image with a lot of histology sections in a series (look at image).
How can I separate and export the two images in the middle in an automatic way? I will have hundreds of these big images and there would probably be around 10-15 histological sections in one image.
I have tried to use watershed algorithm, but it detects several objects within a section and it didn't make a clear border between each section. I hope some of you got an better idea?
Beside that, is it possible to export the individual images afterwards without each section are touching each other? To show you how I would like the end product to look alike, I have used PhotoShop (PS) to isolate the section.
Thank you for your help

6 Comments

Can you provide more info about the problem? For example:
1) Large images containing multiple histology slices, will they always contain 2 complete histology slices, or does the number of complete histology slices vary among images?
2) Do the large images have the same dimensions?
3) Are histological slices always intact or some of them have been torn or severely deformed; and are thus no longer rectangular?
I am asking these questions because it is much easier to solve problems of this sort when you incorporate into the segmentation algorithm as much prior knowledge about the data as possible
What are "some PS"?
How did the "some PS" separate the image and replace the neighboring rectangles with textured background?
Nick
Nick on 30 Jun 2018
Edited: Nick on 30 Jun 2018
Ups! - I wrote this post in the evening, so I forgot to write the real name. Well PS is PhotoShop, so I was "cheating", but this is what I would like the end product to look like :)
1) Large images containing multiple histology slices, will they always contain 2 complete histology slices, or does the number of complete histology slices vary among images?
The number can vary among images. Actually there are around 10 histological sections in the real image, but I could only upload a 5MB image, so I had to crop and downscale the image that you can see. However, if the algorithm works on this image it would most likely also work on the uploaded image :)
2) Do the large images have the same dimensions?
The large images doesn't have the same dimension, but the pixel size is the same no matter what. So it is the dimensions of the sections are more or less the same even tho the big Image differs.
3) Are histological slices always intact or some of them have been torn or severely deformed; and are thus no longer rectangular?
The histological sections are not always interact, so there can also be some space between them, which makes them easy to detect. There could maybe be a deformed section 1 in 400. I cannot garentee if the sections always will be rectangular, but it will have a rectangular edge as you can see here:
If you got more question you can feel free to ask :)
Are all the tops tilted and bottoms tilted? If so we could find the top and bottom and then look for discontinuities.
If the background always lighter and/or smoother than the part in the tile you want to detect?
Yeah, the sections are all a bit tilted and the background are suppose to be lighter than the histological sections. One of the main problem is that the histological sections seems to be very noisy and some small spots are even more brighter than the background as you can see. When I apply the watershed algorithm it won't work, because there are many local maxima or minima, so I am a bit stuck.

Sign in to comment.

 Accepted Answer

Well I need to go out and do some yard work but I'm attaching what I've got so far. But I thought I'd give it to you partially finished if you want to see what you can do with it. Basically I'm identifying the top and bottom edges and the gradient. See if you can finish it. Basically you have to identify big differences on the top and bottom and associate them. Once you know the locations of the separations/gaps in the top and bottom, you can use poly2mask to erase everything outside of that section and crop it out into a new image.
When you've finished with it, post what you've got and I'll comment on it or fix it.

3 Comments

Hi Image Analyst, Thank you very much for your help! I have never thought about using the difference to define the gaps between section!
You can see the segmentation of my sections down below. How would you crop the sections afterwards, without using a rectangular shape?
Additional info, there are sometimes some gap between each section. It seems like the code is very sensitive and the program includes the gaps as sections too. How can I make the code more genetic, so it doesn't matter if the sections got a gap or not?
Thanks in advance.
Well now it's more complicated. I thought that all your sections were touching like a parade of elephants. Now we see that some are totally alone. So now you need to find the areas and if the area is around 1.5 times the expected area, split it apart, and if it's less than that leave it alone. Maybe you can just use imline() or roipolyold() to have the user do it. If there's only a few hundred images it would be faster for the user to do it than for you to develop an algorithm.
Well... There will be more than 10.000 individual sections, and there will be hundreds of those big images. I know how to solve the problem now! :)
1. Find area of individual sections
2. If area is bigger than 1.8 than expected value => use the elephant algorithm!
Thanks again Image Analyst!

Sign in to comment.

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Asked:

on 27 Jun 2018

Commented:

on 2 Jul 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!