I am trying pass a .png image from the console in matlab to a function called bwconversion. The function I have written does work when I assign the a variable name to the image file in the console screen – i.e.:
>>a = imread('1.png');
>>bwconversion(a);
However I need the code to work whereas I can pass it the file path directly such as:
>>bwconversion('J:\Vision\ColourIm\1.png');
But the above returns errors indicating the image was not passed to the function?
Please find my very basic function below:
function bwconversion(imIn)
%Convert Image to Black and White
gr = rgb2gray(imIn);
bw = im2bw(gr, 0.04);
clear gr;
imshow(bw);
I’ll be grateful for any advice that can be offered!
Why not simply pass the file name as the parameter?