Conversion of a binary matrix(256*256) into another matrix which is decimal(85*85)?

조회 수: 7 (최근 30일)
We have a 256*256 binary matrix , from this we take 3*3 matrix which keeps on increasing firstly row wise upto the end point and then 3 units column wise and then upto the end point , this process continues upto the last pixel . now in the 3*3 matrix we start from (1,1) and move clockwise untill we reach (2,1) storing all the values in an array and converting this binary string into decimal value and storing it into a different matrix.
  댓글 수: 3
Raj Gopal
Raj Gopal 2012년 12월 8일
they are non overlapping tiles,and index is from 1 to 256 so there are 255 blocks which is divisible by 3.
Walter Roberson
Walter Roberson 2012년 12월 8일
1-3, 4-6, 7-9, 10-12, 13-15, 16-18, 19-21, 22-24, 25-27, 28-30, 31-33, 34-36, 37-39, 40-42, 43-45, 46-48, 49-51, 52-54, 55-57, 58-60, 61-63, 64-66, 67-69, 70-72, 73-75, 76-78, 79-81, 82-84, 85-87, 88-90, 91-93, 94-96, 97-99, [....] 238-240, 241-243, 244-246, 247-249, 250-252, 253-255, 256 - ????

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

답변 (1개)

Matt J
Matt J 2012년 12월 6일
편집: Matt J 2012년 12월 6일
Assuming the binary matrix is 255x255, you could do it the following way, where I use MAT2TILES from the File Exchange.
A=rand(255)>.5; %fake binary input image
C=mat2tiles(char(A+'0'),[3,3]);
idx=[1 4 7 8 9 6 3 2];
B=cellfun(@(c)c(idx),C,'uni',0);
B=bin2dec(vertcat(B{:}));
result=reshape(B,size(C));
  댓글 수: 2
Raj Gopal
Raj Gopal 2012년 12월 8일
first of all i am using 2 for loops to select the 3*3 matrix and then i'm not getting any idea how to save the converted decimal value into another matrix.
Matt J
Matt J 2012년 12월 8일
편집: Matt J 2012년 12월 8일
I'm not sure how that's relevant to the solution I gave you, or why it's even an issue. The solution I gave you performs all steps, including saving the result to another matrix.
Also, since you know how to create matrices, (e.g. the 256x256 matrix you have now) and to pull data out of them (e.g. 3x3 blocks), it's not clear what difficulty you're having putting data back into one.

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by