How to generate data from image

Hi. Im using this code to generate data from image. But it doesn’t nt show an output.

I = imread(‘FileName.png’);

imshow(I)

Get start and end-points of the line as user input

Theme

[xi,yi] = getpts

y = min(yi):max(yi);

x = xi(1).*ones(size(y))

Get colors of each point

Theme

z = I(y,x,:slight_smile:

Hi @jeanneeeeette

check if you’re in the correct parth or write full path, for example in windows:

I = imread("C:/User/Documents/image.png");

or in linux:

I = imread("/home/user/Documents/image.png");

Anyway getpts is not yet implemented in image package.

Regards

1 Like

how about this?

f=openfig(‘Capture.png’); % open the figure
H=findobj(f,‘type’,‘line’); %handle the object
x=get(H,‘XData’); % get x axis data
y=get(H,‘YData’); % get y axis data

x=cell2mat(x); %convert x axis data to matrix
y=cell2mat(y); %convert y axis data to matrix

[m,n]=size(x); %get the number of rows and columns of x matrix
[r,p]=size(y); %get the number of rows and columns of y matrix
figure;

for i=1:r
plot(x(i,:),y(i,:))
hold on
grid on
end

i want to generate data from image. im so naive in it.

im also trying this

pkg load image
I = imread(‘F:/Capture.png’);

%imshow(I)
new=rgb2gray(I);
figure
imshow(new)
new1=new’;
figure
imshow(new1)

im also trying this
data = get(findobj(open(‘Capture.png’), ‘Type’,‘line’), {‘XData’,‘YData’});
%//Prepare moving average filter of size N
N = 5;
f = @(x) filter(ones(1,N)/N, 1, x);

%//Smooth out the Y data of the LineSeries
hf = open('Capture.png');
for hl = transpose(findobj(hf,'Type','line'))
        set(hl, 'YData', f(get(hl,'YData')));
end;
saveas(hf, 'ttc_delay1000_smooth.fig');

When you’re reading an image file, Octave’s function imread returns 3 matrix each one with one color map,

data = imread("go.png");
# data(:,:,1) has the red component of the image in 0 to 255 scale (RGB with 32 bits)
# data(:,:,2) green component
# data(:,:,3) blue component

rgb2gray gets the 3 matrix and does some calcs to deliver a grayscale image.

If you want to manipulate the image consider those facts and modify the diferent color components as you like, for example you can take the blue component and do over it a convolution with a blur mask.

note:
Remember that openfig is used to open figure files with format .fig

Why doesnt is how an output?
I’ve install the package.

From your description you’re trying to extract plot data from a raster image and that’s not going to work the way you think. Search the web for WebPlotDigitizer and that might do what you want.