Created
November 19, 2022 23:38
-
-
Save ahmadyogi543/90862e86cd471712458c669108ad8bdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear; | |
clc; | |
% memuat citra awal | |
img = imread("lenna.png"); | |
% dapatkan tinggi dan lebar citra | |
[img_height, img_width] = size(img); | |
% kuantisasi citra dari 0 - 255 ke 0 - 9 | |
quantized_img = round(9/255 * img); | |
% buat sebuah wadah baru untuk citra patterning | |
pattern_img = zeros(3 * img_width); | |
% looping citra terkuantisasi | |
for x = 1:img_height | |
for y = 1:img_width | |
index = quantized_img(x, y) + 1; | |
pattern = get_pattern(index); | |
m = 1 + 3*(x - 1); | |
n = 1 + 3*(y - 1); | |
pattern_img(m:m + 2, n:n + 2) = pattern; | |
end | |
end | |
imwrite(pattern_img, "hasil.png"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment