Clear Filters
Clear Filters

fenêtrage d'une image scannographie

2 views (last 30 days)
si vous plait comment je peux appliquer un fenêtrage sur une image Dicom selon les paramètres de centre de la fenêtre et de largeur de la fenêtre voila les valeurs des paramètres (WL=40 WW=85)

Accepted Answer

Image Analyst
Image Analyst on 2 Jun 2024
help conv2
CONV2 Two dimensional convolution. C = CONV2(A, B) performs the 2-D convolution of matrices A and B. If [ma,na] = size(A), [mb,nb] = size(B), and [mc,nc] = size(C), then mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]). C = CONV2(H1, H2, A) first convolves each column of A with the vector H1 and then convolves each row of the result with the vector H2. If n1 = length(H1), n2 = length(H2), and [mc,nc] = size(C) then mc = max([ma+n1-1,ma,n1]) and nc = max([na+n2-1,na,n2]). CONV2(H1, H2, A) is equivalent to CONV2(H1(:)*H2(:).', A) up to round-off. C = CONV2(..., SHAPE) returns a subsection of the 2-D convolution with size specified by SHAPE: 'full' - (default) returns the full 2-D convolution, 'same' - returns the central part of the convolution that is the same size as A. 'valid' - returns only those parts of the convolution that are computed without the zero-padded edges. size(C) = max([ma-max(0,mb-1),na-max(0,nb-1)],0). See also CONV, CONVN, FILTER2, XCORR2. Note: XCORR2 is in the Signal Processing Toolbox. Documentation for conv2 doc conv2 Other uses of conv2 codistributed/conv2 gpuArray/conv2 tall/conv2
There are other windowed functions, for example stdfilt, imgaussfilt, etc.. It really depends on what you want to do with the pixels inside the window.
  6 Comments
rami
rami on 3 Jun 2024
Je pense que la solution est similaire à ce code, mais il manque quelque chose.
info=dicominfo('1.2.156.14702.1.1000.16.2.20220802014611796000200030141');
image=int16(dicomread('1.2.156.14702.1.1000.16.2.20220802014611796000200030141'));
image=image.*info.RescaleSlope+info.RescaleIntercept;
MAX=max(image(:));
MIN=min(image(:));
value1=info.WindowCenter-floor(info.WindowWidth/2);
value2=info.WindowCenter+floor(info.WindowWidth/2);
me=(MAX-MIN)/(value2-value1);
b=MIN-(me*value1);
for i=1:length(image)
for j=1:width(image)
if image(j,i)>=value2
image(j,i)=MAX;
elseif image(j,i)<=value1
image(j,i)=MIN;
else
image(j,i)=me*image(j,i)+b;
end
end
end
figure,imshow(image,[])
Image Analyst
Image Analyst on 4 Jun 2024
Don't use "image" as the name of your variable since it's the name of a built-in function.
Do not use the index j to loop over the width of the image. Since j is the column, not row, j should be the second index, not the first. Otherwise you'll get an index out of range error. Try this:
info = dicominfo('1.2.156.14702.1.1000.16.2.20220802014611796000200030141');
grayImage = int16(dicomread('1.2.156.14702.1.1000.16.2.20220802014611796000200030141'));
% Display image.
subplot(1, 2, 1);
imshow(grayImage,[])
axis('on', 'image');
impixelinfo
title('Original Image')
grayImage = grayImage.*info.RescaleSlope + info.RescaleIntercept;
maxGrayLevel = max(grayImage, 'all')
minGrayLevel = min(grayImage(:))
value1 = info.WindowCenter-floor(info.WindowWidth/2)
value2 = info.WindowCenter+floor(info.WindowWidth/2)
me = (maxGrayLevel-minGrayLevel) / (value2-value1)
b = minGrayLevel - (me * value1)
[rows, columns, numberOfColorChannels] = size(grayImage)
for row = 1 : rows
for column = 1 : columns
if grayImage(row, column)> = value2
grayImage(row, column) = maxGrayLevel;
elseif grayImage(row, column)<=value1
grayImage(row, column) = minGrayLevel;
else
grayImage(row, column) = me*grayImage(row, column)+b;
end
end
end
% Display image.
subplot(1, 2, 2);
imshow(grayImage,[])
axis('on', 'image');
impixelinfo
title('Modified Image')

Sign in to comment.

More Answers (0)

Categories

Find more on DICOM Format in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!