フィルターのクリア

Does Otsu is also used for color image segmentation.

10 ビュー (過去 30 日間)
Aamir Ishaq
Aamir Ishaq 2018 年 3 月 29 日
回答済み: Walter Roberson 2018 年 7 月 1 日
I have applied Otsu on this image and get this black & white segmented image. Is it possible to get the same segment in its original color. I mean the dog, flowers and some grass under the dog should by as it is in original and rest of the image becomes black.
I = imread('D:\Dog.jpg');
I = rgb2gray(I);
imshow(I)
level = multithresh(I);
seg_I = imquantize(I,level);
figure
imshow(seg_I,[]);
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 3 月 29 日
編集済み: KALYAN ACHARJYA 2018 年 3 月 29 日
It may be possible. In segmented images, there are two descriptors, whether it is a dog or flower? You can consider it by assuming blob area, largest is dog and rest are flowers. Based on the position of pixel information (Edit original Image).

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2018 年 3 月 29 日
The whole principle of Otsu is to work on intensities. So you could apply Otsu to the grayscale intensities, or the red channel intensities, or the blue channel intensities, etc, or some intensity derived from all 3 RGB channels, but the Otsu method has no concept of colour.
For colour segmentation, you need a different technique. You could use the Colour Thresholder App. Also look at the various topics at the bottom of the Segmentation help page.
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 3 月 29 日
Sir his question title is different, question description is different, I have commented on it. Am I right?
Image Analyst
Image Analyst 2018 年 7 月 1 日
Different than what? I think Guillaume's answer is fine and addresses the posters need.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 7 月 1 日
Yes,
I = imread('D:\Dog.jpg');
Ig = rgb2gray(I);
imshow(Ig)
level = multithresh(Ig);
seg_Ig = imquantize(Ig,level);
figure
imshow(seg_Ig,[]);
I_masked = I .* repmat( cast(seg_Ig-1, class(I)), 1, 1, size(I,3) );
figure
imshow(I_masked);
imquantize returns double when used in that form, and when given a single input value, the results of imquantize are 1 (value less than the threshold) and 2 (value greater than the threshold) . We subtract 1 to make those into 0 and 1, make the result into the same data type as the input image is, and replicate it along the third dimension to have the same number of color planes that the input image has. The multiplication then acts to mask the original image, turning the pixels black whereever the image intensity was lower than the threshold.

Community Treasure Hunt

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

Start Hunting!

Translated by