Skip to content

Instantly share code, notes, and snippets.

@robdanet
robdanet / ppm_minim.c
Last active September 11, 2015 02:34
Source code for blog post http://thesourcecodenotes.blogspot.co.uk/2015/09/create-image-and-pixel-structure-for.html The code creates a 256x256 PPM image with a white background and only on red pixel located in the center of it.
/*
Source code for blog post http://thesourcecodenotes.blogspot.co.uk/2015/09/create-image-and-pixel-structure-for.html
The code creates a 256x256 PPM image with a white background and only one red pixel located in the center of it.
by Antonio Molinaro, 2015.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
@robdanet
robdanet / emboss_ppm.c
Last active January 8, 2019 18:09
Implementation of an embossing filter in c for PPM images
/*
Source code for blog post http://thesourcecodenotes.blogspot.co.uk/2015/09/imaage-processing-in-c-enbossing-filter.html
The code is an implementation of an embossing filter in c for PPM images.
by Antonio Molinaro, 2015.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
@robdanet
robdanet / rgb2gray.py
Created July 18, 2021 15:16
RGB to Grayscale in Python
## Original code from the series on image processing in python
## Read the tutorial at https://thesourcecodenotes.blogspot.com/2021/07/image-processing-in-python.html
from PIL import Image, ImageTk
import tkinter as tk
def rgb2gray(input_image):
if input_image.mode != 'RGB':
return None
else:
@robdanet
robdanet / brightness.py
Created July 18, 2021 15:27
How to modify an image's brightness in python
## Original code from the series on image processing in python
## Read the tutorial at https://thesourcecodenotes.blogspot.com/search/label/brightness
from PIL import Image, ImageTk
import tkinter as tk
def brightness(input_image, value):
@robdanet
robdanet / contrast.py
Created July 18, 2021 15:29
How to modify an image's contrast in Python (contrast-stretching)
## Original code from the series on image processing in python
## Read the tutorial at https://thesourcecodenotes.blogspot.com/search/label/contrast-stretching
from PIL import Image, ImageTk
import tkinter as tk
def contrast(input_image, value):
if input_image.mode != 'L' and input_image.mode != 'P':
@robdanet
robdanet / graylevel_histogram.py
Created July 20, 2021 00:22
Gray-level image histogram
## Original code from the series on image processing in python
## Read the tutorial at https://thesourcecodenotes.blogspot.com/2021/07/image-processing-in-python-4-grey-level.html
from PIL import Image, ImageTk
import tkinter as tk
def histogram(input_image):
if input_image.mode != 'L' and input_image.mode != 'P':