I need to add alpha plane mapping in an image and display individual alpha plane and also all added alpha plane result image. How to do it.?
1 次查看(过去 30 天)
显示 更早的评论
I have an image of 250x300 size. I need to add alpha plane mapping with 200 alpha planes in it and display individual alpha planes and also all added alpha plane result image. Please help how to do it.?
0 个评论
回答(2 个)
Image Analyst
2016-2-4
I'm not clear what you want. Why don't you just create an image by adding all the "alpha planes" together? How is what you asked for any different than that? You can even have one such summed image be a transparency over another gray scale image.
0 个评论
Walter Roberson
2016-2-4
Example:
img = imread('YourImage.png');
imgg = rgb2gray(img);
counts = accumarray(imgg(:)+1, 1, [256 1]); %histogram
counts_nz = counts(2:end); %skip level 0
meaningful_levels = find(counts_nz >= 20); %find levels with at least 20 pixels
num_ml = length(meaningful_levels);
masks = cell(num_ml, 1);
for K = 1 : num_ml
this_level = meaningful_levels(K);
masks{K} = double(imgg == this_level);
fig = figure();
image(img, 'AlphaData', masks{K});
title(sprintf('Pixel value %d', this_level));
end
overall_mask = sum(cat(3, masks{:}),3);
image(img, 'AlphaData', overall_mask);
title('All levels together');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!