Skip to content

Instantly share code, notes, and snippets.

@StarJade-Park
Last active July 9, 2017 04:07
Show Gist options
  • Save StarJade-Park/bc3c7d5e90b20c579b92c099bc3780e3 to your computer and use it in GitHub Desktop.
Save StarJade-Park/bc3c7d5e90b20c579b92c099bc3780e3 to your computer and use it in GitHub Desktop.
[RGB histogram] Extract RGB, histogram equalization -> red component and synthesize RGB #Multimedia_Systems #matlab
clc; % Clear the command window.
clear; % Clear workspace variable
close all; % Clear figure windows
% Read the captured image file in MATLAB.
bmp = imread('RGB.bmp');
% Display the image on the screen.
imshow(bmp);
% Extract R, G, and B components of the image and display each of the three Components.
% [Indy] size (variable name) will show You have a 3-dimensional array. You can extract R G, B Components,
% respectively, by reading variable name (:,:, 1), Variable name (:,:, 2), variable name (:,:, 3).
red = bmp(:,:,1);
figure; imshow(red);
green = bmp(:,:,2);
figure; imshow(green);
blue = bmp(:,:,3);
figure; imshow(blue);
% Plot histogram of the R component.
figure; imhist(red);
% Perform "histogram equalization" of the extracted R component, and plot The result.
red_histeq = histeq(red);
figure; imshow(red_histeq);
% Synthesize the original color image using the histogram equalized R Component and display it on the screen.
new_bmp = cat(3, red_histeq, green, blue);
figure; imshow(new_bmp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment