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 个评论

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'] );
I still get the same error, but thanks anyways.
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!

Translated by