How to fuse or overlay multiple masks of clustering results onto the original image in a for loop

7 次查看(过去 30 天)
Something like the final image here but looped for an unknown number of groupings. Iterative imfuse or imoverlay is diminishing the intensity of the colors too much beyond 3 groups and it makes looping impossible when the number of groups is unknown. I was thinking automated binary mask creation for the identified particles in each group but I can't figure out the code to do that.

回答(1 个)

yanqi liu
yanqi liu 2021-12-7
yes,sir
may be use bwlabel and label2rgb to make the maks label to rgb image
then,use imshow handle to set the AlphaData,such as
close all;
clear all;
clc;
im=imread('rice.png');
bw=imbinarize(im,'adaptive');
[L,~] = bwlabel(bw);
Lrgb = label2rgb(L, 'jet', 'w', 'shuffle');
figure; imshow(im, [])
hold on
himage = imshow(Lrgb);
set(himage, 'AlphaData', 0.3);

Community Treasure Hunt

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

Start Hunting!

Translated by