Extract data from contour plot of .png file?

33 visualizaciones (últimos 30 días)
Surendra Gupta
Surendra Gupta el 12 de Oct. de 2020
Comentada: jay shah el 2 de Jun. de 2021
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 comentarios
Rik
Rik el 12 de Oct. de 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
Surendra Gupta
Surendra Gupta el 12 de Oct. de 2020
Thank you.

Iniciar sesión para comentar.

Respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 12 de Oct. de 2020
Editada: Bjorn Gustavsson el 12 de Oct. de 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 comentarios
Bjorn Gustavsson
Bjorn Gustavsson el 2 de Nov. de 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
jay shah el 2 de Jun. de 2021
Can you please explain in detail how to use the function? like how to select diagonal points and color map etc.

Iniciar sesión para comentar.

Categorías

Más información sobre Orange en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by