Generate a Sequence in MATLAB
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 2d NxN image L. I need to convert it to a sequence of pixels L1={k1,k2,....kNxN} row wise
댓글 수: 0
채택된 답변
Walter Roberson
2012년 1월 31일
L1 = reshape(L.',1,[]).'
댓글 수: 7
Walter Roberson
2012년 2월 4일
You are using M = 256. The only way to reshape in to a 1D row of pixels row-wise is if M = 1.
If you want to convert in to rows, then the number of rows you use, M, must be divide the number of elements in the matrix.
I notice that 21845, the number of elements in the matrix, is 257 x 85. 257 is, of course, one greater than 256. Please check your code for an off-by-one error.
Also, please be careful about whether you use M as the 2nd or 3rd parameter of the reshape(). Do you want M rows and however many columns that works out to, or do you want M columns and however many rows that works out to?
Anyhow, as your requirements have changed since your initial question, please post your new requirements.
추가 답변 (1개)
Derek O'Connor
2012년 1월 31일
L1 = L(:)'
댓글 수: 2
Walter Roberson
2012년 1월 31일
That would not take the sequence "row-wise"; it would take them column-wise.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!