Unable to perform assignment because the left and right sides have a different number of elements.
조회 수: 2 (최근 30일)
이전 댓글 표시
I am attempting to swap the pixels of the brightest with the darkest in the image. I get this error but as far as I know they have the same number of elements. I check with numel.
댓글 수: 1
Jan
2022년 11월 19일
If you post code as formatted text, it can be used to create an answer using copy&paste. Screenshots are less useful.
답변 (2개)
the cyclist
2022년 11월 19일
The assignment will only have the same number of elements if maskMax3D and maskMin3D have the same number of TRUE elements. For example, with smaller matrices, so that we can see what is going on:
% Note that these masks do not have the same number of TRUE elements
mask1 = logical([1 1; 1 0]);
mask2 = logical([1 0; 0 1]);
M1 = [2 3; 5 7];
M2 = [11 13; 17 19];
% Therefore these two arrays do not have the same number of elements, and
% cannot be assigned to each other
M1(mask1)
M2(mask2)
댓글 수: 0
Image Analyst
2022년 11월 24일
Not sure what you mean because your question is not complete (no code, no images, no good explanation). Maybe it's this
yourImage = 255 - yourImage;
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
댓글 수: 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!