Memuat
Memuat
Watch every step above performed live, with English narration.
0 plays
Class book
Page 1 / 5
Cover: Class Deep Learning CNN-LSTM Deteksi Pneumonia #2: Praproses Citra Medis: CLAHE, Normalisasi & Augmentasi
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Deep Learning CNN-LSTM Pneumonia Detection Class #2: Medical Image Preprocessing: CLAHE, Normalization & Augmentation”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Here is the final result, three rows of chest X-rays. The top row is the original image, the middle row is after CLAHE which makes the lung structure much clearer, and the bottom row is the augmented result consisting of rotation, zoom, shift, and random brightness. All of this is bundled in the PITORC dataset, ready to be used for training the model. Let's get started. Hello, welcome to episode two of the hybrid CNN-LSTM model series for early detection of lung diseases. Medical images often have low contrast and variation in brightness between X-ray machines. Proper preprocessing helps the model focus on disease patterns, not differences in equipment. In this episode, we apply CLAHE, normalization, and data augmentation, then prepare the PITORC dataset and data loader.
The data underscore lung.py file from the previous episode is already available. Create a new file called preprocess.py. We start with CLAHE, short for Contrast Limited Adaptive Histogram Equalization. Unlike standard histogram equalization which applies to the entire image, CLAHE equalizes contrast per small tile, here 4x4, with a clip limit of 2 to prevent noise from being amplified. This technique is standard for X-ray images.
Next, the augmentation function. Our training data consists of only thousands of images, so we randomly increase its variety every time an image is read. Rotation up to 10 degrees, zoom 90 to 110 percent, shift 3 pixels, and brightness 85 to 115 percent. We use warp affine from OpenCN6 with border reflex to prevent the image edges from being black. Augmentation is intentionally light, as the position of organs in X-rays is quite consistent. Now apply CLAHE to all training, validation, and test data,
then save it to one compressed data underscore ready.npz file, so the next episode doesn't need to repeat preprocessing. We also check the values after normalization to the range 0 to 1, with an average around 0.65.
See the comparison. The top row is the original image, the middle row after CLAHE, showing the rib cage, heart boundary, and lung patterns appear much clearer. The bottom row is the augmented version of the same CLAHE image, slightly rotated, shifted, and changed in brightness. For the model, each version is a new training example.
Finally, wrap the data in a PyTorch dataset. Create a file called dataset underscore lung.py. The class round to dataset reads the npz file, and in the getitem method, it converts the image into a float tensor with one channel, as well as running augmentation only if requested, which is for the training data. The loader function creates a data loader with B64 and shuffling for the training data. We test by taking one batch, with shape 64, 1, 64, 64. Done.
We have applied CLAHE, normalization, and augmentation with OpenCNM, saved the ready-to-use data, and prepared the dataset and PyTorch data loader. In the next episode, we will train the baseline model, which is a CNN, for classification between normal and pneumonia. Currently working on a thesis, dissertation, or AI research in the field of medical imaging? Cerdas Inovasi Digital helps implement deep learning, from CNN, LSTM, hybrid models, up to CAM interpretation and result writing, as well as opening deep learning courses with PyTorch. Want to master the entire series, from the Röntgen dataset to evaluation and CAM grading? All six episodes, complete with PDF step-by-step guides and source code, are available to premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want just one class? Buy single class with lifetime access. Subscribe now on the premium page at cerdasinovasidigital.com Contact our WhatsApp or visit cerdasinovasidigital.com Thank you for watching, See you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →