Last active
August 29, 2015 14:10
-
-
Save metadelete/3a14c2ab8f1a284900e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
%uniform_quantizer.m OCTAVE PROGRAMI ÜZERİNDE ÇALIŞABİLECEK ŞEKİLDE OLUŞTURULMUŞ OCTAVE>matlab VARİ BİR MATEMATİKSEL İŞLEM PROGRAMIDIR FAKAT ÖZGÜR BİR YAZILIMDIR | |
%BU PROGRAM GÖRÜNTÜ İŞLEME DERSİ İÇİN OLUŞTURULMUŞTUR. | |
function [] = uniform_quantizer() | |
x= imread ('lena512.bmp'); | |
[height,width]= size(x); | |
L=input ('input a new number for new picture which Uniform-Quantization will be applied on:'); | |
L=L-1; | |
if (L < 0) | |
print('input must be between 1-255') | |
return | |
elseif (L>256) | |
print('input must be between 1-255') | |
return | |
elseif (L == 0) | |
print('input must be between 1-255') | |
return | |
end | |
B = 256; | |
q = B/L; | |
figure(1);imshow(x) | |
for i = 1:height, | |
for j= 1:width, | |
y(i,j)=floor_quantize(x(i,j),q); | |
end | |
end | |
figure(2);imshow(y) | |
endfunction | |
function [new_val] = floor_quantize(EX,q) | |
new_val=floor(EX/q)*q+q/2; | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lena512.bmp must be in same directory; where your octave terminal is working.
you can put any grey-level picture to see how this function working. just change the name of the picture you want to apply uniform quantization or rearrange it from the source code by changing "lena512.bmp" to yours.