If I divided 512*512 Green plane Image into 8*8 blocks How many blocks will Result?

조회 수: 2 (최근 30일)
I divided 512*512 Green plane Image into 8*8 blocks the result block was not what I expect .I expect the output will be 64 blocks .because I make the size of rows and columns in each block=64 block
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 3월 21일
Ameligege - how are you breaking the image into the 8x8 blocks? Are you using a built-in MATLAB function to do this for you or are you using something that you (or someone else) has written? Please include a sample of the code that you are using.
Ameligege
Ameligege 2015년 3월 21일
[rows, columns , numberOfColorBands] = size(grayImage);
%Divide an image up into blocks by using mat2cell().
blockSizeR = 64; % Rows in block.
blockSizeC = 64; % Columns in block.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols =floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
if numberOfColorBands > 1
ca = mat2cell(rgbImage, blockVectorR, blockVectorC, numberOfColorBands);
else
ca = mat2cell(grayImage, blockVectorR, blockVectorC);
end

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

답변 (2개)

John D'Errico
John D'Errico 2015년 3월 21일
A simple way to do it is by looking at each axis.
On the "x" axis, 512/8 blocks = 64. On the "y" axis, 512/8 blocks = 64.
And 64*64 = (2^6)^2 = 2^12 = 4096. So you should expect 4096 blocks.
Or you could do it by area. How many pixels are in each block? 64. How many pixels are in the entire plane of the image? 512*512 = 262144.
So, assuming you can fit those complete blocks into the region, there would be 262144/64=4096 blocks.
The first approach is of course the correct one, since it lets you ensure that you can fit those complete blocks into the image. As long as 512/8 is an integer, there is no problem.
  댓글 수: 1
Ameligege
Ameligege 2015년 3월 21일
Here is the output I could not access each block individually because the number of blocks

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


Image Analyst
Image Analyst 2015년 3월 21일
It depends on what you're doing with the blocks and how you're creating an output. For example if you use blockproc() and return a single value for each block, you'll get a 64 by 64 image. However if you return an 8x8 block instead of a single value, then the output image will be 512x512. I'm attaching two demos that shows that and several other ways of using blockproc().
  댓글 수: 3
Image Analyst
Image Analyst 2015년 3월 21일
You could get more than 64 if your image is color. Please attach your image so I can inspect it.
Ameligege
Ameligege 2015년 3월 21일
No,thanks .I actually Want it to be 64 blocks , I solve the problem of 81 blocks because I want it to be 64 .And I want to get rid of excess blocks .Here is my Image but I Take only the green layer after resizing it to 512*512

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

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by