Image Processing using Matlab/Octave — Part 2

Adesh Gautam
Apr 12, 2019 · 5 min read

In the previous part we saw what is Image Processing, how it works and some basics of Matlab/Octave. In this part we’ll see color model, some additional functions in Matlab/Octave and how to do basic image enhancement.

What is Color Model ?

RGB Color Model
CMY Color Model
Source

Additional functions in Matlab/Octave

                  img = imread(“lena.png”);
                  imwrite(img, “Lena.png”);
                         imshow(img); 
                  gray_image = rgb2gray(rgb_image);
                     binary = im2bw(rgb_image);
                   hsv_image = rgb2hsv(rgb_image);

Image Enhancement

                    G(x, y) = T[F(x, y)]
                           N = (L - 1) - I
clear all; % clear all variables
close all; % close all figures
clc; % clear command window
% import image package
pkg load image;
% read image
img = imread(“lena.png”);
% convert image into gray and then from uint8 to double
grayscale_img = rgb2gray(img);
% show grayscale image
figure
imshow(grayscale_img);
title(“grayscale image”);
imwrite(grayscale_img, “original.jpg”);
# calculate negative of the image
output = 255 — grayscale_img;
% show output image
figure
imshow(uint8(output));
title(“output image”);
imwrite(uint8(output), “negative_tansformation.jpg”);
                           s = c log(1+r)
c = 45;
output = c * log(1 + grayscale_img);
                             s = c * r^𝛄
r = double(img)/255;
c = 1;
gamma = 0.6;
s = c * (r) .^ gamma;
            Contrast = ( Imax — Imin ) / ( Imax + Imin )
cs = imadjust(gray_img, stretchlim(gray_img),[]);
a      = min(img(:));            %minimum pixel of image X
b = max(img(:)); %maximum pixel of image X
cs_img = (img - a) .* (255 / (b - a));

This story is published in The Startup, Medium’s largest entrepreneurship publication followed by +442,678 people.

Subscribe to receive our top stories here.

The Startup

Get smarter at building your thing. Join The Startup’s +750K followers.