Create an array containing coordinate points

30 ビュー (過去 30 日間)
Savannah D
Savannah D 2020 年 10 月 15 日
コメント済み: Matt J 2020 年 10 月 16 日
I have two images (a reference and annotated image). The reference image is 11250x14008x3 that was stitched together from smaller tiles using imtile. The annotated image was coregistered to the reference image and color ROIs were extracted from the annotations. The tiles were given x_y names (from x001_y001 to x030_y038). I now need to essentially back track through the stitching to find the specific tiles that the ROI would have been in.
I created two arrays, one containing all points for x (1:11250) and y (1:14008) and divided them into cells corresponding to the x_y names of the tiles (i.e., the x-array is 1x30 and y-array is 1x38). I now need to create all the coordinates that would exist in each of those tiles but each tile is 375x375.
indx = im_size(1)/xmax; % im_size refers to the reference image; xmax is 30
xpix1 = 1;
xpix2 = indx;
for m = x(1):x(2) % creates 1x30 cell, with each cell containing 375x1 double
x_coord{m} = [xpix1:xpix2]';
xpix1 = xpix1 + indx;
xpix2 = xpix2 + indx;
if xpix2 > im_size(1)
break
end
end
I did the same thing for y so i have y_coord as 1x38 cell, with each cell containing 375x1 double.
I want to now create coordinates out of those x_coord and y_coord variables, but I am having hard time accessing the infomation within the cells.
  1 件のコメント
Rik
Rik 2020 年 10 月 15 日
Can't you just divide by the tile size and round to find the tile indices?

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

採用された回答

Matt J
Matt J 2020 年 10 月 15 日
編集済み: Matt J 2020 年 10 月 15 日
Usinge mat2tiles from the File Exchange,
[X,Y]=ndgrid(1:11250,1:14008);
X=mat2tiles(X,[375,375]);
Y=mat2tiles(Y,[375,375]);
  2 件のコメント
Savannah D
Savannah D 2020 年 10 月 15 日
This worked great! Thank you!
Matt J
Matt J 2020 年 10 月 16 日
Although, it would save RAM considerably to do,
X=mat2tiles(1:11250,[1,375]);
Y=mat2tiles(1:14008,[1,375]);
so that tile (i,j) could be extracted as,
referenceImage(X{i},Y{j},:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by