Applying Regression Model results on multispectral image

1 visualización (últimos 30 días)
Nagwa
Nagwa el 20 de Sept. de 2022
Respondida: Neha el 6 de Sept. de 2023
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

Respuestas (1)

Neha
Neha el 6 de Sept. de 2023
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!

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by