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

2 次查看(过去 30 天)
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.
m=imread('s1.png');
se = strel('disk',10);
closeBW = imclose(m,se);
figure, imshow(closeBW)
level = multithresh(closeBW);
seg_I = imquantize(closeBW,level);
figure, imshow(seg_I,[])
img_class1=class(m);
fill1=cast(seg_I,img_class1);
m1=fill1.*m;
figure,imshow(fill1,[])
  6 个评论
Warid Islam
Warid Islam 2022-11-2
I have one more query. Is it possible to do further mprphological operation on the above image to perform further segmentation?
DGM
DGM 2022-11-3
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.

请先登录,再进行评论。

回答(1 个)

DGM
DGM 2022-11-2
编辑:DGM 2022-11-2
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
otherwise
error('some error message goes here')
end
... 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 个评论
Image Analyst
Image Analyst 2022-11-3
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 2022-11-4
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by