convert a .png image to gray scale matrix

99 Views Asked by At
  1. I want to import a gray scale .png image into matlab. 2) I want it represented as a scalar field such that each pixel has a corresponding matrix element, and matrix operations can be done on it. 3) the values of each matrix element must correspond to its value on the gray scale.

I am new to this stuff! I am having trouble even importing the file. When I start with the following:

1 I = imread(Schlieren_Flow_pic);

2 image(A)

When I hover my curser over the file name I get a matrix, but No output occurs besides the following:

Error using imread>parse_inputs The file name or URL argument must be a character vector or string scalar.

Error in imread (line 342) [source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});

Not sure what to try...

1

There are 1 best solutions below

0
RPM On

The error message is saying that the imread function is expecting a string. Try passing the filename in with quotes around it. You will probably also have to tell it the extension, so try this:

imread('Schlieren_Flow_pic.png');