Undefined variable or class ERROR when i call my function
Show older comments
my function takes in two inputs the number of random points or pixels (p) and the file name that all the data will be extracted from. and simply outputs those points. here's the relevant part of the code.
function [points] = SelectPPixels(filename,P)
imagedata=imread(filename, 'JPG');
[rows,cols,colors]=size(imagedata);
3 Comments
Walter Roberson
on 22 Aug 2018
You did not say which variable or class is being complained about.
....
To answer your previous (now deleted) question as I see some of the same issues here:
You should initialize points to an appropriate size: otherwise the size it comes out is going to be determined by which locations were randomly chosen.
Remember that jpeg images are almost always color images, so you should probably be copying all three color planes.
Are you passing in the file extension as part of the file name? If you are, then using 'JPG' as part of the imread() call is not needed. Perhaps you instead want
imagedata = imread( [filename '.jpg'] );
The big YeeT
on 23 Aug 2018
Walter Roberson
on 23 Aug 2018
You have not indicated exactly what the error is. Are you storing SelectPPixels in a file SelectPPixels.m that is on your MATLAB path? Perhaps you are trying to call upon SelectPixels instead of SelectPPixels?
Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!