Skip to content

Instantly share code, notes, and snippets.

View uugan's full-sized avatar

Uugan uugan

  • Ulaanbaatar, Mongolia
View GitHub Profile
@uugan
uugan / sobel.cpp
Last active December 16, 2015 13:39
/* Edge detection by sobel */
float EdgeSobel(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
int start = GetTickCount();
short filter_x[3][3] =
{ { -1, 0, 1},
{-2, 0, 2},
{ -1, 0, 1}};
short filter_y[3][3] =
{ { -1, -2, -1},
{0, 0, 0},
/* Median filter star size = 5*/
float MedianFileStar5(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
unsigned char wind[13];
int start = GetTickCount();
int cnt=0;
for(int i=2; i < height - 2; i++)
for(int j=2; j < width - 2; j++){
cnt = 0;
for(int p=-1;p<=1;p++){
for(int k=-1;k<=1;k++){
/* Median filter 5x5 6<sup>th</sup> kernel */
float MedianFile5x5(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
unsigned char wind[25];
int start = GetTickCount();
int cnt=0;
for(int i=2; i< height - 2; i++)
for(int j=2; j< width - 2; j++){
cnt=0;
for(int p=-2;p<=2;p++){
for(int k=-2;k<=2;k++){
/* Smoothing image by homogeneous domain 5x5 */
float Smoothby5x5(unsigned char *inbuf, unsigned char* outbuf, int height, int width){
int start = GetTickCount();
int cnt=0;
int s[9],sum[9];
int a,b,c,d,e,f,g,h,ii,jj,k,l,n,o,p,q,r,ss,t,u,v,w,x,y;
double* out = new double[height*width];
for(int i=2; i<height - 2;i++)
for(int j=2;j<width-2;j++){
/*Finding all letters*/
/* Smoothing image by K nearest neighbors */
float SmoothbyKNN(unsigned char *inbuf, unsigned char* outbuf, int height, int width){
int start = GetTickCount();
int _k = 6; // _k<n*n
int _n = 3; // 3x3
int p = 1; // 3/2
int raz[9];
int tmp=0, cnt=0, sum=0;
double* out = new double[height*width];
for(int i=p;i<height-p;i++)
/* Histogram 2/3 degrees */
float hyperbolic_cube_root(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
int g_min=255;
int g_max=0;
double* histogram = new double[256]; /* histogram array 0..255*/
double* cdf = new double[256]; /*Pf(f) cumulative distrib function */
double* out = new double[height*width];
int start = GetTickCount();
for(int i=0;i<256;i++) {
/* Histogram exponential equalization when alpha = 0.011 */
float exponential_histogram(unsigned char* inbuf, unsigned char* outbuf, int height, int width){
double g_min=255;
double g_max=0;
double* histogram = new double[256];
/* histogram array */
double* cdf = new double[256]; /*Pf(f) values [cumulative distribution function]*/
double* out = new double[height*width];
int start = GetTickCount();
for(int i=0;i<256;i++)
/* Histogram hyperbolic equalization */
float hyperbolic_histogram(unsigned char* inbuf, unsigned char* outbuf, int height,int width){
double g_min=255;
double g_max=0;
double* histogram = new double[256];
double* cdf = new double[256]; /* generates Pf(f) */
double* out = new double[height*width]; /* output array of doubles */
int start = GetTickCount();
for(int i=0;i<256;i++) {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace GVF {
class gvf_field {
const double pi = 3.14159;
@uugan
uugan / MagicSquare.java
Created June 13, 2013 13:33
Shows Magic square by odd, doubly even & singly even numbers
/*************************************************************************
*
* This code generates a magic square for odd or even number.
* Based on methods :
* http://www.1728.org/magicsq1.htm - odd
* http://www.1728.org/magicsq2.htm - doublyEven
* http://www.1728.org/magicsq3.htm - singlyEven
* code by : uugan
* date : 01.06.2013
* Compilation: javac MagicSquare.java