MATLAB Answers

User Defined Montage but filling 12x8 Array

18 views (last 30 days)
Jason
Jason on 19 Jan 2021
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 Comments

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by