changing a matrix size

2 ビュー (過去 30 日間)
abdelillah douhi
abdelillah douhi 2019 年 9 月 6 日
コメント済み: Steven Lord 2019 年 9 月 6 日
Hello,
Basically i want to change a logical matrix size from 144x144 to 512x512, here is the case that i have:
i have two images of the same object with those sizes accordingly with some region of interest approximately in the middle of the 144 image here is a small example:
the matrix of the region is as follows:
[0000000000
0001111000
0000110000
0000000000]
the regions are hazardous but in the middle give or take, i have them all. now i want to apply those regions to the bigger image so i need to expande the matrix to go with the 512x512 image. as follows
[000000000000000000000
000000111111110000000
000000001111000000000
000000000000000000000]
any ideas ?
Regards
  4 件のコメント
Bruno Luong
Bruno Luong 2019 年 9 月 6 日
What you plot are not logical matrix.
Steven Lord
Steven Lord 2019 年 9 月 6 日
I hope you do get the idea now
No, I don't. There are many different ways you could expand a 144-by-144 matrix to be a 512-by-512 matrix. I asked what method you want to use. To make this a bit more concrete, using my 4-by-4 example above:
smallPattern = [0 0 0 1; 0 1 1 0; 0 0 1 0; 1 0 0 0]
Should it be expanded to 10-by-10 by padding?
larger = zeros(10);
% Pad along the bottom and right
largePattern1 = larger; largePattern1(1:4, 1:4) = smallPattern
% Pad along the top and right
largePattern2 = larger; largePattern2(7:10, 1:4) = smallPattern
% Pad on all four sides
largePattern3 = larger; largePattern3(4:7, 4:7) = smallPattern
Should we replicate the rows and columns?
% Each element is roughly equal in size, extra rows go to the
% left and top sections
largePattern4 = repelem(smallPattern, [3 2 3 2], [3 2 3 2])
% Shows some symmetry
largePattern5 = repelem(smallPattern, [2 3 3 2], [3 2 2 3])
Should we replicate the matrix as a whole then trim off the extra pieces?
twelve = repmat(smallPattern, 3);
% Trim the bottom and right
largePattern6 = twelve(1:10, 1:10)
% Trim the border on all four sides
largePattern7 = twelve(2:11, 2:11)
% Trim the top and left
largePattern8 = twelve(3:12, 3:12)
Each of those eight larger patterns is a different matrix, built in some way from the small pattern, and all are 10-by-10.

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

採用された回答

Bruno Luong
Bruno Luong 2019 年 9 月 6 日
編集済み: Bruno Luong 2019 年 9 月 6 日
% A is 144 x 144 input binary matrix
I512 = logical(interp2(...
linspace(0,1,size(A,2)),...
linspace(0,1,size(A,1)),...
double(A),...
linspace(0,1,512),...
linspace(0,1,512)')); % this is the "same" image with size 512 x 512
  2 件のコメント
abdelillah douhi
abdelillah douhi 2019 年 9 月 6 日
編集済み: abdelillah douhi 2019 年 9 月 6 日
thanks for your answer but in fact the matrix of the roi ( the cercle) is logical, or else my program wont work, i tryed your solution it did solve the problem on the image but the outcom of the program didn't give exactly the values that i wanted didn't give any actualy.
abdelillah douhi
abdelillah douhi 2019 年 9 月 6 日
thank you very much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by