My note about segmentation from previous available tutorial.
I reproduce the code from the main reference:
https://towardsdatascience.com/efficient-image-segmentation-using-pytorch-part-1-89e8297a0923
additional reference:
https://www.v7labs.com/blog/image-segmentation-guide
https://setosa.io/ev/image-kernels/
https://www.robots.ox.ac.uk/~vgg/data/pets/
https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728
Image segmentation is a technique to isolate pixels belonging to specific objects in an image.
Image segmentation partitions/segments : Objects. Backgrounds, and Boundaries. Image segmentation extends image classification by outlining the object's boundary to pinpoint the corresponding object. There are three types of segmentation:
- Semantic Segmentation
- Instance Segmentation
- Panoptic Segmentation
## Dataset
The daset used in this repo is from [The Oxford-IIIT Pet Dataset](https://www.kaggle.com/datasets/julinmaloof/the-oxfordiiit-pet-dataset) . After being annnotated the image became a trimap image. Which is an image with 3 scaled value with respect to the object, boundaries, and background.
![](https://private-user-images.githubusercontent.com/15936043/257140017-a1ac3571-a5c3-4451-94ca-00787c2ad992.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQ5NDUwNjUsIm5iZiI6MTcxNDk0NDc2NSwicGF0aCI6Ii8xNTkzNjA0My8yNTcxNDAwMTctYTFhYzM1NzEtYTVjMy00NDUxLTk0Y2EtMDA3ODdjMmFkOTkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTA1VDIxMzI0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM3YmEwN2U5ODNiYjI3YTMzMTQ4ZDY5N2UzOTcxMDgyYzE4OTJjNWZmNzdmNWNjZDAwOTNhODJhYjJhYTg5YTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.90g8RxaiG0PZMwivFaqd7SRkwXoOswAm2vT4jhRBenc)
The trimap image is used as the segmentation target.
## Convolution
An image kernel is a small matrix used in machine learning for 'feature extraction', a technique for determining the most important portions of an image. The process known as convolution.
![](https://private-user-images.githubusercontent.com/15936043/257148400-8eed8d17-989d-44fb-bd8e-4279999768d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQ5NDUwNjUsIm5iZiI6MTcxNDk0NDc2NSwicGF0aCI6Ii8xNTkzNjA0My8yNTcxNDg0MDAtOGVlZDhkMTctOTg5ZC00NGZiLWJkOGUtNDI3OTk5OTc2OGQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTA1VDIxMzI0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZkOGFmZGExZThiNzc3YmZjYTNlYTc3YzgxNWZmMWFkMjcxNjk1M2JkYjUxYTA1MTM0YTJhOGU5ODRhOTJlODkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IV14Loff9BA2tuyvXDBe5EfJNaBOLDasW1WsRWT8r6M)
## Depth-wise Separable Convolution
![](https://private-user-images.githubusercontent.com/15936043/257149059-cb358010-4e9c-44b2-91f6-7085033d52ef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQ5NDUwNjUsIm5iZiI6MTcxNDk0NDc2NSwicGF0aCI6Ii8xNTkzNjA0My8yNTcxNDkwNTktY2IzNTgwMTAtNGU5Yy00NGIyLTkxZjYtNzA4NTAzM2Q1MmVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTA1VDIxMzI0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwODBmODU1OTgwNTJjOWY5MTUxZjNhODIzNDQ5NjBlNGJhYTUzYjI2YTAyNzMzNTE5M2Q5NjNkOTU3ZGQ5OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.I4rxSZMrKFn8vmvGKNUvhuSkXG4X5EiX8hRqcstBnS0)