Skip to content
Snippets Groups Projects
Commit f23488f7 authored by Philip Monaco's avatar Philip Monaco
Browse files

Add gitignore to data folder

parent e8c57123
Branches 7-create-function-to-batch-shuffle-training-data
No related tags found
No related merge requests found
*
*/
!.gitignore
\ No newline at end of file
%% Cell type:markdown id:441343d0-e422-4dae-b988-9130e5a0d565 tags:
## Packages
os: Operating system interface
OpenCV: cv2 `pip install opencv-python>=4.5.5`
%% Cell type:code id:d7e56e0e-7eec-429d-940b-c3337db4b4dc tags:
``` python
import os
import cv2 #vision task package opencv-python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
```
%% Cell type:markdown id:67180bd5-c307-4d97-ac64-a6f7980ce32d tags:
## Load Data
%% Cell type:code id:9997df6a-7b70-4060-9e0c-a8c0ed6c3737 tags:
``` python
files = os.listdir('./data/ISIC2018_Task3_Training_Input')
len(files), files[:10]
```
%% Output
(10015,
['ISIC_0024306.jpg',
'ISIC_0024307.jpg',
'ISIC_0024308.jpg',
'ISIC_0024309.jpg',
'ISIC_0024310.jpg',
'ISIC_0024311.jpg',
'ISIC_0024312.jpg',
'ISIC_0024313.jpg',
'ISIC_0024314.jpg',
'ISIC_0024315.jpg'])
%% Cell type:markdown id:abf26e08-49e0-4f39-8b1e-66504dd70fbf tags:
# Image Processing and Transformation
%% Cell type:markdown id:6601df9a-0323-40e3-96f1-96c92895e4c9 tags:
### Sample conversion from a single image
%% Cell type:code id:35352bf4-6670-4de9-afe2-7efc51c2b151 tags:
``` python
#Using imread to import the image as a Blue, Green, Red composit image
image_data_BGR = cv2.imread('./data/ISIC2018_Task3_Training_Input/ISIC_0024306.jpg', flags=cv2.IMREAD_COLOR)
```
%% Cell type:markdown id:efdb6191-44b1-4c3e-8684-790958bf100a tags:
As we can see the image is converted to a composite of 3, 2 dimensional numpy arrays. The first array is the Blue values, the second array is the Green values, and the third array is the Red values.
%% Cell type:code id:561e73a8-6c36-4baf-b1e6-3d2e05b0004f tags:
``` python
image_data_BGR.shape
```
%% Output
(450, 600, 3)
%% Cell type:code id:ac323419-fa86-4dd4-a979-ef6b0abcbc15 tags:
``` python
image_data_BW = cv2.imread('./data/ISIC2018_Task3_Training_Input/ISIC_0024306.jpg', flags=cv2.IMREAD_GRAYSCALE)
```
%% Cell type:code id:2cb18b6e-2918-42f6-b6c0-0aff0948abb1 tags:
``` python
df = pd.DataFrame(image_data_BW)
df.max()
```
%% Output
0 171
1 171
2 172
3 171
4 177
...
595 176
596 177
597 177
598 177
599 178
Length: 600, dtype: uint8
%% Cell type:markdown id:4efb6881-8ed3-49a7-b834-f17266938100 tags:
Here we are converting the image into a grayscale and output a 2 dimensional numpy array of the black and white values.
%% Cell type:code id:42ece6b6-581c-4023-97c9-ea1b9f916a70 tags:
``` python
print(image_data_BW)
```
%% Output
[[158 156 157 ... 163 163 164]
[157 158 161 ... 162 163 162]
[156 159 161 ... 162 163 164]
...
[146 147 149 ... 160 160 158]
[143 146 147 ... 161 163 162]
[143 146 146 ... 160 163 161]]
%% Cell type:markdown id:4936bf4f-422e-44cd-9a0a-d95bf7a1a9fa tags:
The image we will turn black and white
<img src="./data/ISIC2018_Task3_Training_Input/ISIC_0024306.jpg" width=300>
%% Cell type:code id:8c686421-44bd-47ca-9d2b-0627477f0903 tags:
``` python
plt.imshow(image_data_BW, cmap='gray')
plt.show()
```
%% Output
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment