Extract data from figure (2024)

1 Ansicht (letzte 30 Tage)

Ältere Kommentare anzeigen

Anton Vernytsky am 8 Mär. 2022

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure

Kommentiert: Mathieu NOE am 16 Mär. 2022

Hello,

i would like to write a code that will calculte the middle of the "bell'.For example y=1 it is the base off the "bell" and the local min point is the top of the "bell" and i need to find the middle of that "bell'' and draw a horizontal line.For example the base is y=1 and the top is y=0.9 so the middle will be line at y=0.95.

This is my code and example of what i want do draw(The red lines).

Thank you.

Extract data from figure (2)

clear all;

clc;

xlsdata=xlsread('ForDataMining.xlsx');

Wavelength=xlsdata(2:2152);

for i=1:2

reflection = xlsdata(2:2152,i+1);

lmin = islocalmin(reflection,"MinSeparation",100);

bellheight=1-lmin;

bellmid=1-bellheight/2;

plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')

hold on

yline(bellmid);

hold off

title('Relative Reflectance-Wavelength')

xlabel('Wavelength[nm]')

ylabel('Relative Reflectance')

grid on

grid minor

figure(i)

end

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Antworten (1)

Mathieu NOE am 8 Mär. 2022

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#answer_912754

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#answer_912754

hello Anton

I created some dummy data - as you didn't provide the excel file

here my suggestion, for one local minimum

Extract data from figure (4)

clear all;

clc;

% some dummy data

Wavelength=1:1000;

reflection = min(ones(size(Wavelength)),1+0.37*sin(Wavelength/150+1.5));

lmin = islocalmin(reflection,"MinSeparation",100);

lmin_value = reflection(lmin);

bellheight=1-lmin_value;

bellmid=1-bellheight/2;

threshold = bellmid; %

[t0_pos,s0_pos,t0_neg,s0_neg]= crossing_V7(reflection,Wavelength,threshold,'linear'); % positive (pos) and negative (neg) slope crossing points

% ind => time index (samples)

% t0 => corresponding time (x) values

% s0 => corresponding function (y) values , obviously they must be equal to "threshold"

y_line = threshold*ones(size(x_line));

figure(1)

plot(Wavelength,reflection,Wavelength(lmin),lmin_value,'ro',x_line,y_line,'r',t0_pos,s0_pos,'db',t0_neg,s0_neg,'dg','linewidth',2,'markersize',12);grid on

legend('signal','local min','threshold','positive slope crossing points','negative slope crossing points');

title('Relative Reflectance-Wavelength')

xlabel('Wavelength[nm]')

ylabel('Relative Reflectance')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [t0_pos,s0_pos,t0_neg,s0_neg] = crossing_V7(S,t,level,imeth)

% [ind,t0,s0,t0close,s0close] = crossing_V6(S,t,level,imeth,slope_sign) % older format

% CROSSING find the crossings of a given level of a signal

% ind = CROSSING(S) returns an index vector ind, the signal

% S crosses zero at ind or at between ind and ind+1

% [ind,t0] = CROSSING(S,t) additionally returns a time

% vector t0 of the zero crossings of the signal S. The crossing

% times are linearly interpolated between the given times t

% [ind,t0] = CROSSING(S,t,level) returns the crossings of the

% given level instead of the zero crossings

% ind = CROSSING(S,[],level) as above but without time interpolation

% [ind,t0] = CROSSING(S,t,level,par) allows additional parameters

% par = {'none'|'linear'}.

%With interpolation turned off (par = 'none') this function always

%returns the value left of the zero (the data point thats nearest

% to the zero AND smaller than the zero crossing).

%

% check the number of input arguments

error(nargchk(1,4,nargin));

% check the time vector input for consistency

if nargin < 2 | isempty(t)

% if no time vector is given, use the index vector as time

t = 1:length(S);

elseif length(t) ~= length(S)

% if S and t are not of the same length, throw an error

error('t and S must be of identical length!');

end

% check the level input

if nargin < 3

% set standard value 0, if level is not given

level = 0;

end

% check interpolation method input

if nargin < 4

imeth = 'linear';

end

% make row vectors

t = t(:)';

S = S(:)';

% always search for zeros. So if we want the crossing of

% any other threshold value "level", we subtract it from

% the values and search for zeros.

S = S - level;

% first look for exact zeros

ind0 = find( S == 0 );

% then look for zero crossings between data points

S1 = S(1:end-1) .* S(2:end);

ind1 = find( S1 < 0 );

% bring exact zeros and "in-between" zeros together

ind = sort([ind0 ind1]);

% and pick the associated time values

t0 = t(ind);

s0 = S(ind);

if ~isempty(ind)

if strcmp(imeth,'linear')

% linear interpolation of crossing

for ii=1:length(t0)

%if abs(S(ind(ii))) >= eps(S(ind(ii))) % MATLAB V7 et +

if abs(S(ind(ii))) >= eps*abs(S(ind(ii))) % MATLAB V6 et - EPS * ABS(X)

% interpolate only when data point is not already zero

NUM = (t(ind(ii)+1) - t(ind(ii)));

DEN = (S(ind(ii)+1) - S(ind(ii)));

slope = NUM / DEN;

slope_sign(ii) = sign(slope);

t0(ii) = t0(ii) - S(ind(ii)) * slope;

s0(ii) = level;

end

end

end

% extract the positive slope crossing points

ind_pos = find(sign(slope_sign)>0);

t0_pos = t0(ind_pos);

s0_pos = s0(ind_pos);

% extract the negative slope crossing points

ind_neg = find(sign(slope_sign)<0);

t0_neg = t0(ind_neg);

s0_neg = s0(ind_neg);

else

% empty output

ind_pos = [];

t0_pos = [];

s0_pos = [];

% extract the negative slope crossing points

ind_neg = [];

t0_neg = [];

s0_neg = [];

end

end

2 Kommentare

Keine anzeigenKeine ausblenden

Mathieu NOE am 8 Mär. 2022

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#comment_2027014

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#comment_2027014

and now the multiple local minima code :

Extract data from figure (6)

clear all;

clc;

close all

% some dummy data

Wavelength=1:1000;

reflection = min(ones(size(Wavelength)),1+0.55*sin(Wavelength/330).*sin(Wavelength/50+1.5));

lmin = islocalmin(reflection,"MinSeparation",100);

lmin_index = find(lmin);

lmin_value = reflection(lmin);

plot(Wavelength,reflection,Wavelength(lmin),lmin_value,'ro');

hold on

title('Relative Reflectance-Wavelength')

xlabel('Wavelength[nm]')

ylabel('Relative Reflectance')

for ci = 1:numel(lmin_value)

bellheight=1-lmin_value(ci);

bellmid=1-bellheight/2;

threshold = bellmid; %

[t0_pos,s0_pos,t0_neg,s0_neg]= crossing_V7(reflection,Wavelength,threshold,'linear'); % positive (pos) and negative (neg) slope crossing points

% ind => time index (samples)

% t0 => corresponding time (x) values

% s0 => corresponding function (y) values , obviously they must be equal to "threshold"

% keep closest t0_neg t0_pos values from lmin_value

[val,indd] = min(abs(lmin_index(ci)-t0_neg));

t0_neg_selected = t0_neg(indd);

[val,indd] = min(abs(lmin_index(ci)-t0_pos));

t0_pos_selected = t0_pos(indd);

x_line = [t0_neg_selected t0_pos_selected];

y_line = threshold*ones(size(x_line));

plot(x_line,y_line,'r','linewidth',2,'markersize',12);grid on

end

hold off

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [t0_pos,s0_pos,t0_neg,s0_neg] = crossing_V7(S,t,level,imeth)

% [ind,t0,s0,t0close,s0close] = crossing_V6(S,t,level,imeth,slope_sign) % older format

% CROSSING find the crossings of a given level of a signal

% ind = CROSSING(S) returns an index vector ind, the signal

% S crosses zero at ind or at between ind and ind+1

% [ind,t0] = CROSSING(S,t) additionally returns a time

% vector t0 of the zero crossings of the signal S. The crossing

% times are linearly interpolated between the given times t

% [ind,t0] = CROSSING(S,t,level) returns the crossings of the

% given level instead of the zero crossings

% ind = CROSSING(S,[],level) as above but without time interpolation

% [ind,t0] = CROSSING(S,t,level,par) allows additional parameters

% par = {'none'|'linear'}.

%With interpolation turned off (par = 'none') this function always

%returns the value left of the zero (the data point thats nearest

% to the zero AND smaller than the zero crossing).

%

% check the number of input arguments

error(nargchk(1,4,nargin));

% check the time vector input for consistency

if nargin < 2 | isempty(t)

% if no time vector is given, use the index vector as time

t = 1:length(S);

elseif length(t) ~= length(S)

% if S and t are not of the same length, throw an error

error('t and S must be of identical length!');

end

% check the level input

if nargin < 3

% set standard value 0, if level is not given

level = 0;

end

% check interpolation method input

if nargin < 4

imeth = 'linear';

end

% make row vectors

t = t(:)';

S = S(:)';

% always search for zeros. So if we want the crossing of

% any other threshold value "level", we subtract it from

% the values and search for zeros.

S = S - level;

% first look for exact zeros

ind0 = find( S == 0 );

% then look for zero crossings between data points

S1 = S(1:end-1) .* S(2:end);

ind1 = find( S1 < 0 );

% bring exact zeros and "in-between" zeros together

ind = sort([ind0 ind1]);

% and pick the associated time values

t0 = t(ind);

s0 = S(ind);

if ~isempty(ind)

if strcmp(imeth,'linear')

% linear interpolation of crossing

for ii=1:length(t0)

%if abs(S(ind(ii))) >= eps(S(ind(ii))) % MATLAB V7 et +

if abs(S(ind(ii))) >= eps*abs(S(ind(ii))) % MATLAB V6 et - EPS * ABS(X)

% interpolate only when data point is not already zero

NUM = (t(ind(ii)+1) - t(ind(ii)));

DEN = (S(ind(ii)+1) - S(ind(ii)));

slope = NUM / DEN;

slope_sign(ii) = sign(slope);

t0(ii) = t0(ii) - S(ind(ii)) * slope;

s0(ii) = level;

end

end

end

% extract the positive slope crossing points

ind_pos = find(sign(slope_sign)>0);

t0_pos = t0(ind_pos);

s0_pos = s0(ind_pos);

% extract the negative slope crossing points

ind_neg = find(sign(slope_sign)<0);

t0_neg = t0(ind_neg);

s0_neg = s0(ind_neg);

else

% empty output

ind_pos = [];

t0_pos = [];

s0_pos = [];

% extract the negative slope crossing points

ind_neg = [];

t0_neg = [];

s0_neg = [];

end

end

Mathieu NOE am 16 Mär. 2022

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#comment_2045374

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/1666184-extract-data-from-figure#comment_2045374

hello Anton

if my submission has filled your expectations, do you mind accepting it ?

tx

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

Reporting and Database AccessMATLAB Report Generator

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Tags

  • figure
  • plot

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by Extract data from figure (8)

Extract data from figure (9)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

Kontakt zu Ihrer lokalen Niederlassung

Extract data from figure (2024)

FAQs

How do I extract data from an image? ›

Follow these steps to use OCR to copy text from an image:
  1. Open your OCR app to scan a document.
  2. Wait until your app prompts you to scan or until it has recognized text.
  3. Scan the image.
  4. Edit or extract text from the document.

How to extract data from graph to excel? ›

Extracting Data from Chart or Graph
  1. Step 1 : Consider an Excel sheet where you have a chart similar to the below image.
  2. Step 2 : Then click on Insert, select Module, and copy the below code into the text box.
  3. Step 3 : Then save the sheet as a macro−enabled template and click F5 to run the module.
Jul 20, 2023

Can Excel extract data from an image? ›

Save the image on your computer. Open an Excel workbook and click the Data tab on the Ribbon. Choose From Picture from the Get & Transform Data group, Picture From File, then browse and select the saved picture. The Data from Picture window will open on the right side of the workbook, as shown in the screenshot below.

Is there a way to extract text from an image? ›

The process is similar in the mobile apps for Android and iOS. Open up an image with text in it, and you'll see an option to copy the onscreen text. The extracted text can be copied to the clipboard, used as a web search, or even translated with another tap.

What is the online tool to extract data from image? ›

Plotdigitizer is an online data extraction tool that allows users to extract data from images in numerical format. In short, it reverse-engineers your visual graphs into numbers. The software comes with plenty of useful and time-saving features.

How do you extract data? ›

How does Data Extraction work?
  1. Identifying Data Sources.
  2. Source Connection.
  3. Query or Retrieval.
  4. Data Transformation and Loading.
  5. Web Scraping.
  6. API-Based Extraction.
  7. Text Extraction (Natural Language Processing – NLP)
  8. OCR.
Jan 5, 2024

How do I extract data from a JPEG graph? ›

You can use an OCR to extract the values and can even try fine-tuning it to capture the symbols. You can correlate the bounding boxes to find the values. Then you can use simple logic to capture the symbols and correlate them on the axis for the value. You can also use an LLM to understand the semantics of the chart.

Can you extract data from a chart? ›

To get the underlying data in a table or chart in Excel, Powerpoint, PDF, or PNG format, hover and click on the control wheel, select Export and select the desired format. See screenshot for details.

What is the program to extract data points from a graph? ›

Opensource computer vision assisted software to help extract numerical data from images of plots, maps and much more.

How to digitize a figure? ›

Here are simple, easy steps for digitizing graph & plot images using PlotDigitizer:
  1. Step 1: Scanning the plot or graph to create the image. ...
  2. Step 2: Uploading the plot or graph image to PlotDigitizer. ...
  3. Step 3: Editing the image. ...
  4. Step 4: Selecting the type of the graph. ...
  5. Step 5: Calibrating the graph.

How to extract Excel from image? ›

Click Data > Data From Picture > browse and select the picture file > Open.
  1. The image should only depict the data you want to import. If necessary, crop the image.
  2. Avoid images that depict data from an angle - the perspective should be head-on and focused.

How to extract data from graph in PDF to Excel? ›

Step 1: Open a PDF file in Acrobat. Step 2: Click on the “Export PDF” tool in the right pane. Step 3: Choose “spreadsheet” as your export format, and then select “Microsoft Excel Workbook”. Step 4: Click “Export.” If your PDF documents contain scanned text, Acrobat will run text recognition automatically.

How to extract text from an image for free? ›

Frequently Asked Questions (FAQs)
  1. Head to imagetotext.io.
  2. Upload or copy/paste your image into the input box.
  3. Press the submit button.
  4. Copy the extracted text, or download it as a text file.

What information can be extracted from a photo? ›

For example, if the image is a photograph taken by a digital camera, the camera typically generates metadata about the camera and the photo's settings, including aperture, resolution, focal length, shutter speed, ISO speed, camera brand and model, date and time when the image was created, and the GPS location where it ...

How do I convert an image to Excel? ›

Converting JPG to Excel has never been easier, and here's a step-by-step guide to get you started:
  1. Go to the Image to PDF converter.
  2. Upload the JPG you wish to convert.
  3. Click Convert to PDF.
  4. Upload the converted PDF to the PDF to Excel converter.

Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 5983

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.