이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hellow, i have reconstruct an image of 16x16 pixels and all the pixels are in a vector of 256 elements P(256) , is it necessary to change P to a dimension P(16,16) to show it in an image. I thought it would but i tried it and it gives a error. Hope for a positive answer :)
채택된 답변
Walter Roberson
2011년 5월 9일
0 개 추천
image(reshape(P,16,16))
What error are you getting?
댓글 수: 10
Fiboehh
2011년 5월 21일
I tried this and the error is:
figure
image(reshape(X,16,16))
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Is it always necessary to reshape, because all the images i produce in my ART code have the form: I(x,1) where x is mostly 256,512 or 1024 and maybe you know there is a standard solution?
Matt Fig
2011년 5월 21일
So show the output of this, placed right before the line that errors:
size(X)
Walter Roberson
2011년 5월 21일
If you have an array which is 512 or 1024, then that contradicts your initial claim that "all the pixels are in a vector of 256 elements P(256)"
If you _do_ have 512 or 1024 elements, then what outcome do you want? Still a 16 x 16 pixel outcome? If so then how do you want multiple input elements to be mapped in to the 16 x 16 output ?
Fiboehh
2011년 5월 22일
No, in my program the user can choice how many pixels. And i must visualize the result. So if they select a 1024 image, i must image the vector with 1024 elements (thats a 32x32 pixel image). So i though that i must make it 32x32 to use it in image. Because image(vector) doesn't do anything...
Also when the user choice a 256(16x16) image, i also have to image it... so i need it in general.
I hope you understand it now :)
But already thank you very much!
Matt Fig
2011년 5월 22일
L = sqrt(length(P));
if floor(L)~=L
error('Bad vector length.')
else
image(reshape(P,L,L))
end
Walter Roberson
2011년 5월 22일
The only thing I might do differently than Matt's answer is to use numel(P) instead of length(P)
Matt Fig
2011년 5월 22일
@Walter, just out of curiosity why choose NUMEL over LENGTH?
Are you still suspicious that Fiboehh hasn't supplied a vector?
Walter Roberson
2011년 5월 22일
numel() covers the case where a non-vector was supplied but length() does not. numel() is as easy to write and covers more cases, so one might as well use it unless one explicitly wishes the code to error out in the case where a non-vector was supplied (and if so then why not test for that condition to make it obvious that one did not simply "overlook" that possibility ?)
That and I don't want to have another go around with someone saying, "But that failed for me" only to have it turn out that they had supplied a non-vector.
Matt Fig
2011년 5월 22일
Exactly as I thought... Good enough!
Walter Roberson
2011년 5월 22일
Note that 512 does not have an integer square root. Fiboehh, what do you want to have happen if 512 is selected?
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Images에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
