how to solve the transpose error of an image
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
0 Kommentare
Antworten (1)
ag
am 6 Aug. 2024
Bearbeitet: ag
am 6 Aug. 2024
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!
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!