该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我的code是这样的
ThresholdRatio =0.8;
edge_threshold=max_grad* ThresholdRatio; % pixels' gradient which is larger than edge_threshold will be recognized as edge
max_pixel=max(max(smoothed_image(:)));
min_pixel=min(min(smoothed_image(:)));
threshold_1=min_pixel+(max_pixel-min_pixel)/3; % thresholds for pseudo coloration
threshold_2=max_pixel-(max_pixel-min_pixel)/3;
[h12 w12]=size(smoothed_image);
pseudo_gradient_R=[];
pseudo_gradient_G=[];
pseudo_gradient_B=[];
k1=1; % weights of RGB channels, they can be modified to acquire best performance
k2=1;
k3=1;
for i=1:h12
for j=1:w12
smoothed_image(i,j)=rad2deg(smoothed_image(i,j));
if gradient_gray(i,j)>=edge_threshold
pseudo_gradient_R(i,j)=255; % color edge with red
pseudo_gradient_G(i,j)=0;
pseudo_gradient_B(i,j)=0;
else
if smoothed_image(i,j) >= min_pixel && smoothed_image(i,j) <= threshold_1
pseudo_gradient_R(i,j)=0; % color rest pixels
pseudo_gradient_G(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*min_pixel)/2*(threshold_1-min_pixel)^k2));
pseudo_gradient_B(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*threshold_1)/2*(min_pixel-threshold_1)^k3));
elseif smoothed_image(i,j) > threshold_1 && smoothed_image(i,j) <= threshold_2
pseudo_gradient_R(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*threshold_1)/2*(threshold_2-threshold_1)^k1));
pseudo_gradient_G(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*threshold_2)/2*(threshold_1-threshold_2)^k2));
pseudo_gradient_B(i,j)=0;
else %(smoothed_image(i,j) > threshold_2) && (smoothed_image(i,j) <= max_pixel)
pseudo_gradient_R(i,j)= 255;
pseudo_gradient_G(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*threshold_2)/2*(max_pixel-threshold_2)^k2));
pseudo_gradient_B(i,j)= abs(255*sin((pi*smoothed_image(i,j)-pi*threshold_2)/2*(max_pixel-threshold_2)^k3));
end
end
end
end
请高手指点
谢谢