123

X=dicomread('abdomen_002.dcm');
X=X-1024;
X=double(X);
WW=400;
WL=40;
for i=1:512
    for j=1:512
        if (X(i,j)>WL+WW/2)
            Y(i,j)=255;
        else if(X(i,j)<WL-WW/2)
              Y(i,j)=0;
            else if(X(i,j)>=WL-WW/2 & X(i,j)<=WL+WW/2)
                Y(i,j)=(X(i,j)+WW/2-WL)*255/WW;
                end 
            end
        end
    end
end
Y=uint8 (Y);
imshow(Y);


你可能感兴趣的:(double)