Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- domain adaptation
- resample
- noise contrast estimation
- 자료구조
- clip intensity values
- pulloff
- remove outliers
- MRI
- sample rows
- rest-api
- Knowledge Distillation
- model-free control
- loss functions
- sidleup
- checkitout
- shadowing
- non parametic softmax
- Inorder Traversal
- Excel
- REINFORCE
- normalization
- scowl
- freebooze
- straightup
- 3d medical image
- fastapi
- Actor-Critic
- thresholding
- objective functions for machine learning
- Policy Gradient
Archives
- Today
- Total
Let's Run Jinyeah
[Python] Brain MRI Thresholding 본문
What is Thresholding?
Thresholding is a type of image segmentation. It converts an image from colour or grayscale into a binary image that is simply black and white.
Overall Process of Thresholding (fixed-level thresholding)
1) load the original image
2) convert it to grayscale
- grayscale images containe pixel values in the range from 0 to 1
3) de-noise image ex.blurring
- not necessary, but important to remove noise to find good threshold value in practice
4) apply the threshold 't'
5) de-noise image
- not necessary, but needed to obtaine smooth and clean binary mask
How to find threshold value 't'?
※ create a histogram of the grayscale image
- interpret the peaks in the histogram to determine an appropriate threshold
Example
★ My application
extract brain region in brain MRI image to improve computational efficiency
1) draw histogram of the grayscale image
# Convert to grayscale image [0,1]
image = image.sum(axis=0)
tmp0 = (image- image.min()) / (image.max() - image.min())
# Draw histogram
plt.hist(tmp0.flatten(), 100)
plt.savefig('gray-scale histogram.png')
plt.close()
2) find threshold (interpret histogram)
- find out that the pixels between [0,0.1] consist of 78% of whole image using cumulative distribution function
- choose the pixel value which is 75 percentile as a threshold value
# generate culminative distribution function(cdf)
pixel_num, bins = np.histogram(tmp0, 100, [0, tmp0.max()])
cdf = np.cumsum(pixel_num) / sum(pixel_num)
# find threshold value
thr = np.where(cdf > 0.75)[0][0]
# or use percentile
thr_percent = 0.75
thr = np.percentile(tmp00, thr_percent * 100)
3) generate binary removing noise
# generate mask
mask = np.zeros_like(tmp0)
for j in range(tmp0.shape[0]):
# mask[j] = tmp[j] > thr
mask[j] = closing(dilation(erosion((tmp0[j] > thr), se), se), se)
'Programming > Medical Image Processing' 카테고리의 다른 글
[Python] MRI Resampling (0) | 2022.07.08 |
---|---|
Magnetic Resonance Imaging (MRI) (0) | 2022.05.13 |
Comments