How do i split an array in to quarters?

3 ビュー (過去 30 日間)
mark
mark 2013 年 11 月 17 日
回答済み: Image Analyst 2013 年 11 月 17 日
I need to:
Read the image file into Matlab. Split the array into quarters along the longer (628) axis. For the first quarter, generate a one-dimensional array containing the sum of the brightness of all the pixels in the now- quartered dimension, computed at each position in the shorter (470) dimension. This array should have 470 elements. Repeat this for the other three quarters.
I don't know how to split the array or the following steps
Help please

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 11 月 17 日
編集済み: Walter Roberson 2013 年 11 月 17 日
Q{1} = YourImage(1:end/2, 1:end/2);
Q{2} = YourImage(end/2+1:end, 1:end/2);
Likewise for the other two quarters.

Image Analyst
Image Analyst 2013 年 11 月 17 日
You forgot to tag it as homework, so I did it for you.
I'll assume the longer dimension is the x or columns dimension and it's a grayscale image. Then here's some hints
[rows, columns, numberOfColorChannels] = size(theImage);
% Get the middle 3 columns to divide the array at.
dividingCols = round([1,2,3] .* columns / 4)
% Do the third quarter. All rows in the third quarter lengthwise.
quarter3 = theImage(:, dividingCols(2):end);
theSum = sum(quarter3(:))

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by