Splitting image in matlab

8 ビュー (過去 30 日間)
Lucas  Buckels
Lucas Buckels 2017 年 3 月 28 日
回答済み: Guillaume 2017 年 3 月 28 日
Need to split an image in matlab into 4 quadrants and swap the top left and bottom left quadrants

回答 (3 件)

Walter Roberson
Walter Roberson 2017 年 3 月 28 日
Hint: [end/2+1:end,1:end/2]

Image Analyst
Image Analyst 2017 年 3 月 28 日
Did you try indexing/assignment:
rgbImage = imread('peppers.png'); % Read input image
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(rgbImage);
outputImage = rgbImage; % Initialize
middleRow = ceil(rows/2);
middleColumn = ceil(columns/2);
% Paste lower left onto upper left.
outputImage(1:middleRow, 1:middleColumn, :) = rgbImage(middleRow+1:end, 1:middleColumn, :);
% Paste upper left onto lower left.
outputImage(middleRow+1:end, 1:middleColumn, :) = rgbImage(1:middleRow, 1:middleColumn, :);
imshow(outputImage);

Guillaume
Guillaume 2017 年 3 月 28 日
Another way:
[height, width, ~] = size(yourimage);
splitimage = mat2cell(yourimage, [ceil(height/2), floor(height/2)], [ceil(width/2), floor(width/2)], size(yourimage, 3));
swappedimage = cell2mat(rot90(splitimage, 2)');

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by