how to solve the transpose error of an image

2 ビュー (過去 30 日間)
dhvani patel
dhvani patel 2015 年 3 月 11 日
編集済み: ag 2024 年 8 月 6 日
InputImage= imread(strcat('C:\Users\lay\Desktop\Project\photo\1.jpg')); figure(5) subplot(1,2,1) imshow(InputImage); colormap('gray'); title('Input image','fontsize',18) InImage=reshape(double(InputImage)',irow*icol,1); [LINE:-195] temp=InImage; me=mean(temp); st=std(temp); temp=(temp-me)*ustd/st+um; NormImage = temp; Difference = temp-m; NormImage = Difference; p = []; aa=size(u,2);
****************************ERROR:- error using ' Transpose on ND array is not defined. Use PERMUTE instead.
Error in face_rec (line 195) InImage=reshape(double(InputImage)',irow*icol,1);

回答 (1 件)

ag
ag 2024 年 8 月 6 日
編集済み: ag 2024 年 8 月 6 日
Hi Dhvani, the error message that you are facing is caused by using "transpose" function on an ND array. Transpose function can only be used on a Vector(1D array) or Matrix(2D array).
To resolve this issue, either of the below workarounds can be used:
1. Convert the image matrix to a gray scale, this will convert the "InputImage" from an ND array to a 2D array(matrix). The below code snippet demonstrates how to convert image to a gray scale, and use transpose:
grayImage = rgb2gray(InputImage);
reshapedImage = transpose(rgb2gray(InputImage));
2. Use Permute to reshape the matrix. The below code snippet demonstrates it's usage:
InputImage = imread(strcat('C:\Users\lay\Desktop\Project\photo\1.jpg'));
% Use permute to rearrange the dimensions of the array as per your use case
InImage = reshape(double(permute(InputImage, [2 1 3])), irow*icol, 1);
For more details on "reshape", please refer to the following MathWorks Documentation page: https://www.mathworks.com/help/matlab/ref/reshape.html
Hope this helps!

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by