필터 지우기
필터 지우기

Why is the lenna image rotated?

조회 수: 2 (최근 30일)
niniki
niniki 2022년 2월 22일
댓글: niniki 2022년 2월 23일
Opened lenna.raw file in figure.
By the way, the image is rotated 90 degrees counterclockwise. It was a 256x256 image, and I printed the image using mat2gray.
I'm curious as to why and how the image is spinning.
please help me thank you.
  댓글 수: 4
DGM
DGM 2022년 2월 22일
When you read the image into a rectangular geometry such as in this call:
a = fread(raw,[256,256])
understand that what you're doing is taking the raw data in the file (a vector) and devectorizing it. This is the same as reshaping any other vector.
Consider the example:
myimagevector = 1:25; % pretend this is the image data
myimagematrix = reshape(myimagevector,5,5)
myimagematrix = 5×5
1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25
The contents of the vector are placed columnwise into the output geometry. If the original data had been written out row-wise, then the result will be transposed -- not rotated.
@yanqi liu is correct. All you likely need to do is transpose the incoming image.
niniki
niniki 2022년 2월 23일
Thanks to your answer, I understood perfectly!!!! ^^b

댓글을 달려면 로그인하십시오.

채택된 답변

yanqi liu
yanqi liu 2022년 2월 22일
yes,sir,may be check
when read it,should use ' to transposition the matrix
fid = fopen('lena256.raw', 'rb');
x = fread(fid, [256, 256], 'uint8=>double').' ;
fclose(fid);
figure; imshow(x, [])

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by