Borrar filtros
Borrar filtros

Trying to display the segmentation result in the same type as of the original image.

2 visualizaciones (últimos 30 días)
I have applied basic segmentation on my image. 's1.png' is the original image and 's2.png' is the segmented image. I want the segmented image to be of the same type(color) as the original image. However, I am unable to do it. Any suggestions would be appreciated.
se = strel('disk',10);
closeBW = imclose(m,se);
figure, imshow(closeBW)
level = multithresh(closeBW);
seg_I = imquantize(closeBW,level);
figure, imshow(seg_I,[])
  6 comentarios
Warid Islam
Warid Islam el 2 de Nov. de 2022
I have one more query. Is it possible to do further mprphological operation on the above image to perform further segmentation?
DGM el 3 de Nov. de 2022
Since I don't really understand the use of multithresh() and imquantize() in this method, I don't know if that's appropriate or not. You certainly could do morphological operations on any image; I just don't know if it's appropriate in this context.

Iniciar sesión para comentar.

Respuestas (1)

DGM el 2 de Nov. de 2022
Editada: DGM el 2 de Nov. de 2022
I think you might be asking how to programmatically cast and scale an image to a specific class from any class. If that's the case, then this is how you'd do it within the scope of base MATLAB/IPT:
% say we want to cast/scale image FG to have the same class as image BG
outclass = class(BG);
switch outclass
case 'uint8'
FG = im2uint8(FG);
case 'double'
FG = im2double(FG);
case 'single'
FG = im2single(FG);
case 'uint16'
FG = im2uint16(FG);
case 'int16'
FG = im2int16(FG);
case 'logical'
FG = logical(FG); % this is a great way to create problems
error('some error message goes here')
... because the primary parameter (the class name) is embedded in the function names. It's almost like you're being tempted to use eval() or something.
You could also use cast(), which does support the class name as a parameter, but then you'll have to take care to correctly scale the data for each possible combination, because cast() doesn't scale anything.
... or you can just use MIMT imcast():
FG = imcast(FG,class(BG));
That said, you might presume that your input image is uint8 and just use im2uint8(). That's certainly fallible,but it's simple and might cover your needs.
  9 comentarios
Image Analyst
Image Analyst el 3 de Nov. de 2022
Sorry we can't help you. We don't know what the original image looks like so we don't know what you want to find in it. Somehow you found a squiggly shape but apparently it's not good for some unknown (to us) reason. And we don't even know what would be the perfect, ideal segmentation since you're not showing us that, so we don't know how to alter your existing, bad segmentation to give you the ideal, perfect, optimal segmentation. Good luck though.
Warid Islam
Warid Islam el 4 de Nov. de 2022
The original slice of image looks like 'original.png'. The '8004.3.png' is the segmented region annotated by the radiologists. The next slice of image is 'IMG-0012-00219.png' which is the image I want to segment next. I tried to segment the 'IMG-0012-00219.png' using the region growing algorithm but it didn't work. The next thing I tried was further segmenting the already segmented '8004.3.png'. I am assuming that segmenting this region would give the segmenting result of the next slice('IMG-0012-00219.png') of the original image.

Iniciar sesión para comentar.


Más información sobre Image Data Workflows en Help Center y File Exchange.





Community Treasure Hunt

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

Start Hunting!

Translated by