Applying Regression Model results on multispectral image

3 次查看(过去 30 天)
I used the regression learner application to develop a regression model. Then exported the model to the workspace.
I want to apply the exported model on a multispectral image.
I used foor loop to convert the image to table and apply the model. it works but it took very long time. I believe there is much faster way.
My code:
B = My_image;
a = size (B,1);
b = size (B,2);
c = size (B,3);
D = zeros(a,b);
l=0;
for i = 1:a
for j = 1:b
S.B01 = B(i,j,1);
S.B05 = B(i,j,5);
S.B06 = B(i,j,6);
S.B07 = B(i,j,7);
S.B09 = B(i,j,9);
S.B10 = B(i,j,10);
S.B11 = B(i,j,11);
S.B12 = B(i,j,12);
S.B02 = B(i,j,2);
S.B03 = B(i,j,3);
S.B04 = B(i,j,4);
S.B08 = B(i,j,8);
S.B8a = B(i,j,13);
TT = struct2table( S );
l = FDT.predictFcn(TT);
D (i,j) = l;
end
end
May anyone help me in that
Thank You

回答(1 个)

Neha
Neha 2023-9-6
Hi Nagwa,
I understand that you want to convert a multispectral image to a table, so that it can be used in the regression model. Instead of using a nested loop to convert each pixel of the image to a table and apply the model, you can vectorize the process as vectorized code often runs much faster than the corresponding code containing loops.
For more information on vectorization, you can refer to the following documentation link:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by