How to map each pixel in the image from the colour bar and assign temperature to the pixel from the colour bar

13 ビュー (過去 30 日間)
P VINOD NAIDU
P VINOD NAIDU 2024 年 12 月 19 日
回答済み: DGM 2024 年 12 月 20 日
I have image with the colour bar, i want to map to RGB values each pixel in the image with the RGB values in the colour bar and assign the temperature of that particular pixel in the colour bar to the mapped pixel in the image and i also need store the information of the each pixel of the image in Excel such as X, Y, R, B, G and the temperature mapped from the colour bar.

回答 (1 件)

DGM
DGM 2024 年 12 月 20 日
There are now quite a few examples of this on the forum. Here's another.
% the image
inpict = imread('image.jpeg');
imshow(inpict)
% get the colorbar extents
cblim = [500 1100];
% get the colormap from the colorbar
cbar = imcrop(inpict,[461.51 10.51 7.98 199.98]);
cbar = im2double(cbar);
CT0 = flipud(permute(mean(cbar,2),[1 3 2]));
% refine the color table
N = 256; % number of quant levels
x0 = linspace(0,1,size(CT0,1));
xf = linspace(0,1,N);
CT = interp1(x0,CT0,xf); % interpolate to form new CT
% convert the pseudocolor image into an estimate of temperature
T = rgb2ind(inpict,CT,'nodither');
T = rescale(T,cblim(1),cblim(2));
% create a mask over the annotations
sz = size(inpict);
P = {[99.15 265.9; 100.5 284.6; 164.5 283.6; 162 263.4], ...
[397.8 6.224; 475.1 6.224; 476.5 233.5; 397.8 233.4]};
mask = poly2mask(P{1}(:,1),P{1}(:,2),sz(1),sz(2)) ...
| poly2mask(P{2}(:,1),P{2}(:,2),sz(1),sz(2));
% try to inpaint all the holes created by the annotations
T = regionfill(T,mask);
% show the temperature map and add a datatip for visualization
hi = imshow(T,[],'border','tight');
datatip(hi,69,280);

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by