0% found this document useful (0 votes)
19 views

Script RGB Hasil Proses Membuka File

The document contains Matlab code to perform several image processing tasks on an input image, including separating the RGB color channels, converting to grayscale, applying binary thresholding using Otsu's method, and generating histograms of the color channels and grayscale image. The code loads an image, extracts the red, green, and blue color channels, converts the image to grayscale, applies binary thresholding using a fixed threshold and Otsu's method, and generates histograms to analyze the distributions of pixel values in each color channel and the grayscale image.

Uploaded by

Ramadhan Putra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Script RGB Hasil Proses Membuka File

The document contains Matlab code to perform several image processing tasks on an input image, including separating the RGB color channels, converting to grayscale, applying binary thresholding using Otsu's method, and generating histograms of the color channels and grayscale image. The code loads an image, extracts the red, green, and blue color channels, converts the image to grayscale, applies binary thresholding using a fixed threshold and Otsu's method, and generates histograms to analyze the distributions of pixel values in each color channel and the grayscale image.

Uploaded by

Ramadhan Putra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SCRIPT RGB HASIL

clc;clear;close all; Proses Membuka File :


I =
imread('D:\MODULSIMUL\PAKDEBI.jpg');
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
Red = cat(3,R,G*0,B*0);
Green = cat(3,R*0,G,B*0);
Blue = cat(3,R*0,G*0,B);

figure, imshow(I);
figure, imshow(Red);
figure, imshow(Green);
figure, imshow(Blue);
Hasil RGB :

SCRIPT GRYCYCLE HASIL

J = rgb2gray(I);
figure, imshow(J);

SCRIPT KONVERSI GRYCYCLE KE POLA BINER HASIL

K = im2bw(J,0.5);
figure, imshow(K);
SCRIPT METODE OTSU HASIL

L = graythresh(J);
M = im2bw(J,L);
figure, imshow(M);

SCRIPT HISTOGRAM HASIL

clc;clear;close all;
Img = imread('D:\MODULSIMUL\PAKDEBI.jpg ');

R = Img(:,:,1);
G = Img(:,:,2);
B = Img(:,:,3);

Red = cat(3,R,G*0,B*0);
Green = cat(3,R*0,G,B*0);
Blue = cat(3,R*0,G*0,B);

Gray = rgb2gray(Img);

rmap = zeros(256,3);
rmap(:,1) = 0:255;
rmap = rmap/255;

gmap = zeros(256,3);
gmap(:,2) = 0:255;
gmap = gmap/255;

bmap = zeros(256,3);
bmap(:,3) = 0:255;
bmap = bmap/255;

figure,
imshow(Img);

figure,
histogram(R(:),256,'FaceColor','r','EdgeCol
or','r')
hold on
histogram(G(:),256,'FaceColor','g','EdgeCol
or','g')
histogram(B(:),256,'FaceColor','b','EdgeCol
or','b')
set(gca,'XLim',[0 255])
set(gca,'YLim',[0 10000])

hold off

figure,
imshow(Red), colormap(rmap), colorbar
figure,
histogram(R(:),256,'FaceColor','r','EdgeCol
or','r')
set(gca,'XLim',[0 255])
set(gca,'YLim',[0 10000])
grid on

figure,
imshow(Green), colormap(gmap), colorbar

figure,
histogram(G(:),256,'FaceColor','g','EdgeCol
or','g')
set(gca,'XLim',[0 255])
set(gca,'YLim',[0 10000])
grid on

figure,
imshow(Blue), colormap(bmap), colorbar

figure,
histogram(B(:),256,'FaceColor','b','EdgeCol
or','b')
set(gca,'XLim',[0 255])
set(gca,'YLim',[0 10000])
grid on

figure,
imshow(Gray), colormap(gray), colorbar

figure,
histogram(Gray(:),256,'FaceColor',[.5 .5
.5],'EdgeColor',[.5 .5 .5])
set(gca,'XLim',[0 255])
set(gca,'YLim',[0 10000])
grid on

You might also like