필터 지우기
필터 지우기

fenêtrage d'une image scannographie

조회 수: 2 (최근 30일)
rami
rami 2024년 6월 2일
댓글: Image Analyst 2024년 6월 4일
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)

채택된 답변

Image Analyst
Image Analyst 2024년 6월 2일
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
rami
rami 2024년 6월 3일
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 2024년 6월 4일
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')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by