Hi i have a set of data which is temperatures in degree celsius ranging from 10 deg to 250 deg but i need to plot only the temperatures ranging from 20 and 70 degrees .

19 Ansichten (letzte 30 Tage)
Hi i have a set of data which is temperatures in degree celsius ranging from 10 deg to 250 deg but i need to plot only the temperatures ranging from 20 and 70 degrees . like i have data in x axis and y axis both are temperature values from thermal image i need to apply temperature limits from 20 deg to 70 deg to plot graph. so please help i tried doing but i could plot based on the rows and columns. not based on the data. please help thanks

Akzeptierte Antwort

DGM
DGM am 25 Mär. 2023
I'm just going to throw this out there while I'm waiting.
For the moment, I'm going to assume that the image is a pseudocolor image in RGB -- a JPG from a camera. This is the messy, difficult case that will be full of problems, but it serves to demonstrate the simple case at the same time. The reason is simple. If we're starting with a pseudocolor image in RGB, the first step is to convert it to temperature data. After that, the steps are the same.
So this is the test image. I've cropped all the decorations off of it, but it originally contained a colorbar with temp limits.
First step is to convert it to temperature data as well as possible. Doing that requires knowing what the original colormap was. I'm going to use a clone of the map used by these FLIR cameras, but otherwise you'd have to estimate it from the image.
% a pseudocolor image
inpict = imread('flirclip.jpg');
% the colormap
CT = flirmap('flir1',256); % attached
% the temperature range of the image
Trange = [18.9 50.9];
% convert the image to temperature data
T = rgb2ind(inpict,CT,'nodither');
T = rescale(T,Trange(1),Trange(2));
Now we have our estimated temperature data. Display it.
% display the image with the original map scaling
imshow(T,[])
colormap(CT)
colorbar
At this point, if you want the colormap scaling to cover a different range, you can set caxis().
% display the image, but change the colormap scaling
imshow(T,[])
colormap(CT)
Trangenew = [35 47];
caxis(Trangenew)
colorbar
... but note that everything outside that range is stuck with the end colors of the map. Maybe you want values outside the selected range to be represented by one single color, or perhaps a color that's not part of the map. You can do that too.
% create an underlay image of the desired matting color
bgcolor = [0 0 0.25]; % pick some color
BG = repmat(permute(bgcolor,[1 3 2]),size(T));
imshow(BG); hold on
% display the image, change the colormap scaling as before
hi = imshow(T,[]);
colormap(CT)
Trangenew = [35 47];
caxis(Trangenew)
colorbar
% create a mask selecting the desired temperature range
mask = T>=Trangenew(1) & T<=Trangenew(2);
% set the overlaid image region to be transparent in unwanted regions
% this way the underlaid image shows through
hi.AlphaData = mask;
  3 Kommentare
DGM
DGM am 27 Mär. 2023
If it's a single-channel image with values in units of temperature, then the examples I gave should work, depending on how you want the out-of-range pixels to be represented.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 22 Mär. 2023
xlim([20 70])
Or possibly ylim() instead of xlim()
Or maybe you need clim()
  3 Kommentare
Stephen23
Stephen23 am 25 Mär. 2023
"when i plot after using Xlim and Ylim"
In the simplest case, PLOT should be called before XLIM and YLIM, not after.
DGM
DGM am 25 Mär. 2023
Bearbeitet: DGM am 25 Mär. 2023
I think OP has 2D data; however, it's unclear whether that's raw temperature data or a pseudocolor image.
Can you provide an example image, or otherwise clarify what exactly you have, how you're displaying it, and how you want the excluded data to be represented?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by