How do I load and display an image stored in a separate .mat file?
34 ビュー (過去 30 日間)
古いコメントを表示
I am trying to load an image from a provided file and display the image for a class project. We were given the following bit of code to do this so be gentle with me. The prupose of doing this to use linear algebra to do image compression of the data matrix for the image.
image = load("MAT 350 Project Two MATLAB Image.mat");
figure(1);
imshow(image);
And I get the following errors.
Error using imageDisplayValidateParams
Expected input number 1, I, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was struct.
Error in images.internal.imageDisplayValidateParams (line 11)
validateattributes(common_args.CData, {'numeric','logical'},...
Error in images.internal.imageDisplayParseInputs (line 79)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
0 件のコメント
採用された回答
Matt J
2024 年 12 月 14 日 14:35
編集済み: Matt J
2024 年 12 月 14 日 14:38
If you look at,
disp(image)
you will see that image is a struct as the error message is telling you. What you probably meant to do is,
image=load("MAT 350 Project Two MATLAB Image.mat").whatever_the_name_of_the_variable_in_the_file_is
4 件のコメント
Walter Roberson
2024 年 12 月 14 日 17:37
variable = load(file)
is defined in the documentation. If file is a .mat file then the output is a struct array with one field for each variable in the .mat file. If file is a text file, then the output is a 2D numeric array.
Stephen23
2024 年 12 月 14 日 19:13
"I wish that was in the documentation for the load function."
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!