フィルターのクリア

How to generate an RGB image from a 8-bit greyscale image that has an uneven background?

3 ビュー (過去 30 日間)
ct8
ct8 2023 年 12 月 6 日
編集済み: DGM 2023 年 12 月 6 日
I have a grey scale 8-bit image which I want to transform into an RGB image where R(red) corresponds to the brightest features, B(blue) stands for the darkest feature and G(green) corresponds to the grey features. At the same time I want the background to be black to highlight the colored features. The problem I have is that my background is (i) highly non-uniform, (ii) grey, while there are important grey features within the image. If I apply a global background subtraction, the important grey features will be lost from the image. I have attached an image from a published paper here. Any help in solving this problem is graetly appreciated. Thank you!
  1 件のコメント
DGM
DGM 2023 年 12 月 6 日
編集済み: DGM 2023 年 12 月 6 日
What is the intent?
  1. a linear colormapping process based on intensity
  2. a discrete colormapping based on some sort of classification
What is the image?

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

採用された回答

DGM
DGM 2023 年 12 月 6 日
編集済み: DGM 2023 年 12 月 6 日
I'm not sure where this is going, but maybe this is a start.
% read the image
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1561484/test_image.png');
% try to create a mask that selects the triangles?
% it's probably going to be pretty rough.
trianglemask = imflatfield(inpict,20);
trianglemask = imadjust(trianglemask);
trianglemask = imbinarize(trianglemask,'adaptive','sensitivity',0.77);
trianglemask = imopen(~trianglemask,strel('disk',3)); % despeckle
trianglemask = bwareaopen(trianglemask,500); % get rid of blobs below a given size
% get pixels within the mask
inmask = inpict(trianglemask); % pixels within the mask
imhist(inmask) % show the distribution of values
% what are the limiting values?
% are they the available dynamic range of the numeric class?
%inrange = getrangefromclass(inmask); % [0 255]
% or use image extrema within the mask
inrange = imrange(inmask); % the actual extrema
% or instead of using the extreme values at the tail, come in a bit
%p = 1; % ignore the upper and lower p% of pixels
%inrange = quantile(inmask,[p 100-p]/100); % the specified lower/upper quantile
% add some markers to the histogram
xline(inrange(1));
xline(inrange(2));
% create a pseudocolor image
CT = hsv(384);
CT = flipud(CT(1:256,:));
outpict = gray2pcolor(inpict,CT,inrange,'cdscale'); % attached
outpict = outpict.*trianglemask; % omit the background
imshow(outpict)
% assuming we just want equal-spaced bins?
% these outer bins are adjacent to the limiting values in inrange
edges = linspace(inrange(1),inrange(2),4);
hc = histcounts(inmask,edges);
hc = hc/sum(hc);
% make a grouped bar plot
hb = bar(1,hc);
hb(1).FaceColor = 'b';
hb(2).FaceColor = 'g';
hb(3).FaceColor = 'r';
legend({'low','medium','high'}) % the color is a proxy. describe the data

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by