This project involves processing a dataset of grayscale brain tumour images to create augmented data samples and generate masks for tumour detection. The tasks are performed using Google Colab and include various data augmentation techniques, mask creation, and image segmentation.
- Download the dataset and upload it to Google Colab.
- Unzip the archive file using the provided code.
- Read the dataset and preprocess the images:
- Slice each image
[:, :, 0]
to ensure they are in grayscale. - Resize each image to
[256, 256]
. - Print the number of images in the dataset.
- Slice each image
Due to the small dataset size, augmentation techniques are used to create more samples:
- Crop each image into four parts and resize each part to generate four new data samples.
- Flip each image to generate a new data sample.
- Note: Do not use
numpy.flip
or any similar function.
- Rotate each image by 90° to generate a new data sample.
- Note: Do not use
numpy.rot90
or any similar function.
- Use the
inRange
function to create masks from the dataset images. - Determine the appropriate upper and lower range values to label the tumour using a colour picker.
- Multiply each image by its mask to segment the tumour and plot the result.
- Iterate over each mask to find the indices needed to crop the tumour part:
- Find four indices for each tumor
[row_start : row_end, column_start : column_end]
. - Note: Do not use
cv2.contour
or any similar function.
- Find four indices for each tumor
- Create two numpy arrays,
X
andY
:X
contains the dataset images.Y
contains the masks created for tumours.X
shape:(num_of_images, height, width)
Y
shape:(num_of_images, height, width)
- Python 3.x
- Google Colab
- NumPy
- OpenCV
- Matplotlib
- Clone the repository and upload the dataset to Google Colab.
- Follow the code cells in the provided Colab notebook to preprocess the dataset, perform data augmentation, create masks, and generate X-Y pairs.
- Execute each section of the notebook sequentially to replicate the results.
The processed images and masks can be visualized within the Colab notebook. The results include augmented images, segmented tumors, and localized tumour regions.
Contributions are welcome! Please create a pull request with a detailed description of your changes.
This project is licensed under the Unlicense.