Extract data from contour plot of .png file?
28 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have the attached contour plot figure in .png format. I need to extract the data points form the plot (x,y,z)?
Would someone please help me with the same?
Thanks in advance.
6 Commenti
Rik
il 12 Ott 2020
I hard-coded the coordinates for this example image. It looks like there is an issue with rescaling the data, but I will leave that for you to untangle. Note that this solution does not use the actual colorbar, but convert everything to grayscale first. That is probably done to avoid having to match the actual colors, which can be quite tricky for low resolution images like yours.
%// Import the data:
imdata = importdata('ir_image.png');
Gray = rgb2gray(imdata.cdata);
colorLim = [300 1220]; %// this should be set manually
%// Get the area of the data:
da_tp_lft = [25 13];
da_btm_rgt = [231 287];
dat_area = double(Gray(da_tp_lft(2):da_btm_rgt(2),da_tp_lft(1):da_btm_rgt(1)));
%// Get the area of the colorbar:
ca_tp_lft = [246 13];
ca_btm_rgt = [246 287];
cmap_area = double(Gray(ca_tp_lft(2):ca_btm_rgt(2),ca_tp_lft(1):ca_btm_rgt(1)));
%// Convert the colormap to data:
data = dat_area./max(cmap_area(:)).*range(colorLim)-abs(min(colorLim));
figure(1),clf(1)
imshow(data,[])
colorbar
Risposte (1)
Bjorn Gustavsson
il 12 Ott 2020
Modificato: Bjorn Gustavsson
il 12 Ott 2020
In case the conversion of the colormap to grayscale doesn't work well (i.e. multiple colours mapping to the same gray-level) I once had to solve this problem, and came up with a solution working reasonably well with the functions attached.
HTH
3 Commenti
Bjorn Gustavsson
il 2 Nov 2020
Ok, the scan2D2data function expects an rgb-image as input, not a string with path to an image-file. So call it something like this:
imfilename = 'your-png-filename.png';
im_rgb = imread(imfilename);
[M_out] = scan2D2data(img_in);
Then the function will interactively query you about the colour-map and the range the data, and the image-region of the data.
HTH
jay shah
il 2 Giu 2021
Can you please explain in detail how to use the function? like how to select diagonal points and color map etc.
Vedere anche
Categorie
Scopri di più su Orange in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!