Rescale a grayscale image

조회 수: 31 (최근 30일)
Ana Gabriela Guedes
Ana Gabriela Guedes 2021년 11월 1일
댓글: Ana Gabriela Guedes 2021년 11월 1일
Hi!
I have this input image: CT-MONO2-16-ankle.dcm and I need to read this dicom file and rescale the grayscale image by mapping the full range of its content intensity to the scale of the corresponding image data type (this is what is written in the assignment I have to do).
Can someone please help me? I don't understand what am I supposed to do in here or how since the image is already in grayscale.
Thank you!

채택된 답변

DGM
DGM 2021년 11월 1일
Consider the following image. The image content does not span the extent of the allowable range.
A = dicomread('CT-MONO2-16-ankle.dcm');
getrangefromclass(A) % standard data range for the class of A
ans = 1×2
-32768 32767
[min(A(:)) max(A(:))] % show the actual range of the data
ans = 1×2
32 4080
Normalize it and then scale/cast it to whatever the intended working image class is supposed to be. If you assume that it should remain int16:
B = im2int16(mat2gray(A)); % normalize, cast and scale
[min(B(:)) max(B(:))] % show the actual data range
ans = 1×2
-32768 32767
Or if you want uint8:
C = im2uint8(mat2gray(A)); % normalize, cast and scale
[min(C(:)) max(C(:))] % show the actual data range
ans = 1×2
0 255
Or if you just want double:
D = mat2gray(A); % normalize
[min(D(:)) max(D(:))] % show the actual data range
ans = 1×2
0 1
  댓글 수: 1
Ana Gabriela Guedes
Ana Gabriela Guedes 2021년 11월 1일
Thank you so much!! It worked for what I needed

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by