Undefined variable or class ERROR when i call my function
显示 更早的评论
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 个评论
Walter Roberson
2018-8-22
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
2018-8-23
Walter Roberson
2018-8-23
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?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!