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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
func sum(slice []float64) float64 { | |
sum := 0.0 | |
for _, v := range slice { |
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
const VSHADER_SOURCE = ` | |
attribute vec4 a_Position; | |
void main() { | |
gl_Position = a_Position; | |
gl_PointSize = 10.0; | |
}`; | |
const FSHADER_SOURCE = ` | |
precision mediump float; |
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
function initVertexBuffers(gl, vertices) { | |
const vertexBuffer = gl.createBuffer(); | |
if (!vertexBuffer) { | |
console.error("Gagal dalam membuat buffer object!"); | |
return -1; | |
} | |
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); | |
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); |
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
function loadShader(gl, type, source) { | |
const shader = gl.createShader(type); | |
gl.shaderSource(shader, source); | |
gl.compileShader(shader); | |
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { | |
alert( | |
`Terjadi kesalahan saat proses kompilasi shaders: ${gl.getShaderInfoLog( | |
shader | |
)}` |
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
function initShaderProgram(gl, vsSource, fsSource) { | |
const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource); | |
const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource); | |
const shaderProgram = gl.createProgram(); | |
gl.attachShader(shaderProgram, vertexShader); | |
gl.attachShader(shaderProgram, fragmentShader); | |
gl.linkProgram(shaderProgram); | |
if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { |
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; | |
img = imread("images/baboon.jpg"); | |
img = rgb2gray(img); | |
[img_height, img_width] = size(img); | |
d1 = [ |
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 |
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; | |
% load citra skala kelabu | |
img = imread("path ke gambar"); | |
hist_img = img; | |
total_piksel = rows(img) * columns(img); | |
max_piksel = max(max(img)); |
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
% load citra dan ambil ukurannya (width dan height) | |
cover_img = imread("https://picsum.photos/512/512"); | |
[img_height, img_width] = size(cover_img); | |
pesan = "aku sangat ingin terbang"; | |
panjang_pesan = length(pesan) * 8; | |
% menggunakan fungsi uint8 untuk mengambil ascii | |
ascii_pesan = uint8(pesan); |
NewerOlder