下面代码执行效率很低,如何优化
imshow(lena_laplacian_g1_a1_opt);title('Laplacian Processing Image Lena with g1(α=1)','Color','r'); %加标题
%使用g1(m,n) alpha=2进行处理并显示
subplot(2,2,3);
for i = 2:1:255
for j = 2:1:255
laplacian_x = imadd(lena_img(i+1,j),lena_img(i-1,j));
laplacian_x = imsubtract(laplacian_x,imadd(lena_img(i,j),lena_img(i,j)));
laplacian_y = imadd(lena_img(i,j+1),lena_img(i,j-1));
laplacian_y = imsubtract(laplacian_y,imadd(lena_img(i,j),lena_img(i,j)));
laplacian_operator = imadd(laplacian_x,laplacian_y);
lena_laplacian_g1_a2_opt(i,j) = imsubtract(lena_img(i,j),imadd(laplacian_operator,laplacian_operator));
end
end
imshow(lena_laplacian_g1_a2_opt);
上面代码执行效率很低,一运行,CPU 100% ,不能退出
[ 本帖最后由 eight 于 2007-11-27 09:37 编辑 ]
回复 #1 graduate 的帖子
看看矢量化编程的帖子,进行优化
页:
[1]