Thresholding a CT scan image.

34 Ansichten (letzte 30 Tage)
Oguz Oz
Oguz Oz am 6 Dez. 2021
Kommentiert: Oguz Oz am 6 Dez. 2021
Hello everyone.
I am a university student from Turkey and currently working on detection and clasification of cancerous regions on lung CT scans and i have a major problem at the moment. This is my first question on this community tab so i want to explain my problem very clearly.
In the beginning we have an image sized by 512x512 in DICOM format the first thing i did is converting this image from DICOM to JPG the reason for this is in DICOM format the image has some type of blur when it is converted to JPG that blur goes away after that i added new lines and colums to this image to make it 550x550 so i can create equal square windows sized by 50x50 and after expanding the image i converted it from JPG to grayscale image with rgb2gray command after this point i am starting to thresholding the image and also this is where my problem starts.
My advisor told me to make the windows sit on each other and here is an image to explain it better.
Here each different color represents a different window and the next window is one colum away from the previous window so they can overlap each other with only one colum of difference and after extracting the window we find the T value for the it with following formula
T(i,j) = m(i,j) + k*σ(i,j)
Where m(i,j) and σ(i,j) are the local mean and standard deviation in a particular window around any pixel (i,j), respectively.
After finding the T value i convert the window from gray scale image to binary image with imbinarize but it does not work the code i wrote finds every T value for each window but the result is just a black image and i couldnt find any solution if there is a fundemantal problem with my logic please point it out because i cant find it myself the end result should be an image with only ones and zeros where they represent black and white, for example:
And here is the part of my code where i do all this work that i explained:
%% Thresholding the image.
ImageThresh = zeros(550); % An empty shell for our thresholded image.
k = (-0.2); % A fixed value.
a = 1; % a and c represent the lines and their values change with each loop.
b = 1;
c = 1; % b and d represent the colums and their values change with each loop.
d = 1;
for i = 1:11 % This for loop is for lines the reason it goes from 1 to 11 is because of our image's size is 550x550 and our windows are 50x50 so to get 550 it has to loop for 11 times.
for r = 1:500 % Same mentality with the above for loop but it is for the colums and is a bit different.
T = mean2(image(a:c+49,b:d+49)) + (k*std2(image(a:c+49,b:d+49))); % Here we find the threshold value for each window.
ImageThresh(a:c+49,b:d+49) = imbinarize(image(a:c+49,b:d+49),T); % Here we are converting the image to binary image.
b = b+1;
d = d+1;
if d+49 >= 550 % These four if states are here to not pass the boundries of our image (550x550)
d = 1;
end
if b >= 501
b = 1;
end
end
a = a+1;
c = c+1;
if c+49 >= 550
c = 1;
end
if a >= 501
a = 1;
end
end
figure(2);
imshow(ImageThresh), title('Thresholded image');
axis on;
impixelinfo;
I am only a novice at using MATLAB so if my code looks unprofessional i am sorry and thanks to everyone for their comments in advance.
  1 Kommentar
Matt J
Matt J am 6 Dez. 2021
the first thing i did is converting this image from DICOM to JPG the reason for this is in DICOM format the image has some type of blur when it is converted to JPG that blur goes away
That definitely sounds wrong. JPG is a lossy compression method, so it should only make the original DICOM gray values worse.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 6 Dez. 2021
Before implementing the decomposition into tiles, you should probably just try imbinarize(image,'adaptive'), which does something very similar.
  9 Kommentare
Matt J
Matt J am 6 Dez. 2021
Well, like I said, converting to JPEG is a bad thing to do. But if you must convert to JPEG it doesn't seem too hard to threshold the image empirically:
A=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/825090/LIDC-IDRI-0072-1.dcm.jpg');
A = rgb2gray(A);
imshow(A>0.005,[])
Oguz Oz
Oguz Oz am 6 Dez. 2021
Thank you so much for your time, i will try to improve this i believe i can remove the chest from this image thank you again, have a great day.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by