Rotate an image 180 degrees without library functions

48 ビュー (過去 30 日間)
Poojha Palle
Poojha Palle 2022 年 9 月 5 日
回答済み: James Tursa 2022 年 9 月 5 日
I am tasked with rotating an image using a single line of Matlab code. I'm unsure how to do this without using built-in rotate functions. Any help or advice would be appreciated, thank you!
The function I am supposed to write has one input, that being the image, and expects a "results" output that stores the rotated image.
function result = image_rotation(image)
% insert one line of code here
end
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 9 月 5 日
Hint: the J'th row and K'th column of input should become the J'th-last row and K'th-last column

サインインしてコメントする。

回答 (2 件)

Image Analyst
Image Analyst 2022 年 9 月 5 日
Hints: Look at the transpose operator -- the apostrophe. Also look at indexing with a negative 1 step.
[rows, columns, numColorChannels] = size(yourImage);
indexes = rows : -1 : 1;
Do not call your variable "image" since that is the name of an important built-in function.
Good luck with your homework.

James Tursa
James Tursa 2022 年 9 月 5 日
Hint: Take a small example, rotate it 180 degrees, and see where the elements end up. Then consider how you might get that result with indexing into the original matrix.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by