User Defined Montage but filling 12x8 Array
2 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am scanning a sample that has a possible 12x8 locations. The user defines the positons to scan and the scan order is indicated by the number in the cells
I have a 1D cell array containing the images from the scan
imgArray{n}
I also have the row and col locations for each image
row=app.Positions(:,1) %column 1 for row locations
col=app.Positions(:,2) %column 2 for col locations
Whats the best way to create a montage splatting the images in the montage reflecting the positon in the table. For each image i have the row and col positons they were captured in. I would like to always display a 12x8 montage and just put positions where no image was created to e.g. blank (zero)
This was my attempt.
%First create "blank" images of zeros and position in all 12x8 locations
[sy,sx]=size(app.imgArray{1}) % Get size of each image, just used the 1st one as the size doesnt change
B=zeros(sy,sx); %Create a blank image
for j=1:8
for i=1:12
M(i,j)=B; %create a 12x8 array of blank images
end
end
Now positon the real images at their repsective locations
for i=1:m %m is the number of images
r=row(i); c=col(i);
M(r,c)=app.imgArray{i}
end
But I can't get passed creating the montage of blank images:
Error in HPBR/montage (line 1402)
M(i,j)=B;
0 件のコメント
回答 (1 件)
Rohit Pappu
2021 年 3 月 25 日
A possible workaround is as follows
% Create an empty cell array of size 12x8
imgList = cell(96);
% calculate the cell array position for each image based on
% it's row and column
pos = (row-1)*8 + col; % eg. 2nd row 3rd column image has a cell array position of (2-1)*8+3 =11
imgList{pos} = imgArray; % Store the images in a new cell array based on the position they should appear in imtile
imtile(imgList,'GridSize',[12 8]); % Create a 12x8 grid and place the images in the correct position
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!