Tidying up. Allows initial dictionary to be used.

parent e837dcc4
#!/bin/python
import numpy as np
import matplotlib as plt
import pnm
import os
#
# MNIST
#
#
# main results
#
X = pnm.imread('../data/mnist_data.pbm')
Akprox = pnm.imread('./paper/conv-mnist-fwd-kprox/__final_coeffs__.pbm')
Ekprox = pnm.imread('./paper/conv-mnist-fwd-kprox/__final_residual__.pbm')
Dkprox = pnm.imread('./paper/conv-mnist-fwd-kprox/__final_dict_mosaic__.pbm')
Amob = pnm.imread('./paper/conv-mnist-fwd-mob/__final_coeffs__.pbm')
Emob = pnm.imread('./paper/conv-mnist-fwd-mob/__final_residual__.pbm')
Dmob = pnm.imread('./paper/conv-mnist-fwd-mob/__final_dict_mosaic__.pbm')
i = []
for j in range(0,10):
i = i + range( (1100*j), (1100*j+4) )
X_e = X[i,:]
Akprox_e = Akprox[i,:]
Ekprox_e = Ekprox[i,:]
Amob_e = Amob[i,:]
Emob_e = Emob[i,:]
pnm.imsave('mnist-dict-fwd-mob.pbm',Dmob,maxval=1)
pnm.imsave('mnist-dict-fwd-kprox.pbm',Dkprox,maxval=1)
pnm.imsave('mnist-coeff-kprox-extract.pbm',Akprox_e,maxval=1)
pnm.imsave('mnist-residual-kprox-extract.pbm',Ekprox_e,maxval=1)
pnm.imsave('mnist-coeff-mob-extract.pbm',Amob_e,maxval=1)
pnm.imsave('mnist-residual-mob-extract.pbm',Emob_e,maxval=1)
pnm.imsave('mnist-extract.pbm',X_e,maxval=1)
os.system('../src/mosaic_tool mnist-coeff-kprox-extract.pbm mnist-coeff-kprox-mosaic.pbm 40')
os.system('../src/mosaic_tool mnist-residual-kprox-extract.pbm mnist-residual_kprox-mosaic.pbm 40')
os.system('../src/mosaic_tool mnist-coeff-mob-extract.pbm mnist-coeff-mob-mosaic.pbm 40')
os.system('../src/mosaic_tool mnist-residual-mob-extract.pbm mnist-residual-mob-mosaic.pbm 40')
os.system('../src/mosaic_tool mnist-extract.pbm mnist-mosaic.pbm 40')
#
# initialization results
#
D_rand_0 = pnm.imread('./paper/init-kprox-rand-mnist/__initial_dict_mosaic__.pbm')
pnm.imsave('mnist-init-rand-init.pbm',D_rand_0,maxval=1)
D_rand_kprox = pnm.imread('./paper/init-kprox-rand-mnist/__final_dict_mosaic__.pbm')
pnm.imsave('mnist-init-rand-kprox.pbm',D_rand_kprox,maxval=1)
D_rand_mob = pnm.imread('./paper/init-mob-rand-mnist/__final_dict_mosaic__.pbm')
pnm.imsave('mnist-init-rand-mob.pbm',D_rand_mob,maxval=1)
D_samp_0 = pnm.imread('./paper/init-kprox-samp-mnist/__initial_dict_mosaic__.pbm')
pnm.imsave('mnist-init-samp-init.pbm',D_samp_0,maxval=1)
D_samp_kprox = pnm.imread('./paper/init-kprox-samp-mnist/__final_dict_mosaic__.pbm')
pnm.imsave('mnist-init-samp-kprox.pbm',D_samp_kprox,maxval=1)
D_samp_mob = pnm.imread('./paper/init-mob-samp-mnist/__final_dict_mosaic__.pbm')
pnm.imsave('mnist-init-samp-mob.pbm',D_samp_mob,maxval=1)
#
# EINSTEIN (FALTA)
#
#
# main falta
# image of 1160 x 896 broken into 16x16 patches.
# That is 56 patches wide
# we chose a stripe of 40 patches starting at (y=432,x=128)
# that is row 27, col 8 in the patches grid
# so the linear patch position is 27*56+8 = 1520
X = pnm.imread('../data/einstein.pbm')
Akprox = pnm.imread('./paper/conv-einstein-fwd-kprox/__final_coeffs__.pbm')
Ekprox = pnm.imread('./paper/conv-einstein-fwd-kprox/__final_residual__.pbm')
Dkprox = pnm.imread('./paper/conv-einstein-fwd-kprox/__final_dict_mosaic__.pbm')
Amob = pnm.imread('./paper/conv-einstein-fwd-mob/__final_coeffs__.pbm')
Emob = pnm.imread('./paper/conv-einstein-fwd-mob/__final_residual__.pbm')
Dmob = pnm.imread('./paper/conv-einstein-fwd-mob/__final_dict_mosaic__.pbm')
i = range(1520,1560)
X_e = X[i,:]
Akprox_e = Akprox[i,:]
Ekprox_e = Ekprox[i,:]
Amob_e = Amob[i,:]
Emob_e = Emob[i,:]
pnm.imsave('einstein-dict-fwd-mob.pbm',Dmob,maxval=1)
pnm.imsave('einstein-dict-fwd-kprox.pbm',Dkprox,maxval=1)
pnm.imsave('einstein-coeff-kprox-extract.pbm',Akprox_e,maxval=1)
pnm.imsave('einstein-residual-kprox-extract.pbm',Ekprox_e,maxval=1)
pnm.imsave('einstein-coeff-mob-extract.pbm',Amob_e,maxval=1)
pnm.imsave('einstein-residual-mob-extract.pbm',Emob_e,maxval=1)
pnm.imsave('einstein-extract.pbm',X_e,maxval=1)
os.system('../src/mosaic_tool einstein-coeff-kprox-extract.pbm einstein-coeff-kprox-mosaic.pbm 40')
os.system('../src/mosaic_tool einstein-residual-kprox-extract.pbm einstein-residual_kprox-mosaic.pbm 40')
os.system('../src/mosaic_tool einstein-coeff-mob-extract.pbm einstein-coeff-mob-mosaic.pbm 40')
os.system('../src/mosaic_tool einstein-residual-mob-extract.pbm einstein-residual-mob-mosaic.pbm 40')
os.system('../src/mosaic_tool einstein-extract.pbm einstein-mosaic.pbm 40')
#
# einstein init (OK)
#
D_rand_0 = pnm.imread('./paper/init-kprox-rand-einstein/__initial_dict_mosaic__.pbm')
pnm.imsave('einstein-init-rand-init.pbm',D_rand_0,maxval=1)
D_rand_kprox = pnm.imread('./paper/init-kprox-rand-einstein/__final_dict_mosaic__.pbm')
pnm.imsave('einstein-init-rand-kprox.pbm',D_rand_kprox,maxval=1)
D_rand_mob = pnm.imread('./paper/init-mob-rand-einstein/__final_dict_mosaic__.pbm')
pnm.imsave('einstein-init-rand-mob.pbm',D_rand_mob,maxval=1)
D_samp_0 = pnm.imread('./paper/init-kprox-samp-einstein/__initial_dict_mosaic__.pbm')
pnm.imsave('einstein-init-samp-init.pbm',D_samp_0,maxval=1)
D_samp_kprox = pnm.imread('./paper/init-kprox-samp-einstein/__final_dict_mosaic__.pbm')
pnm.imsave('einstein-init-samp-kprox.pbm',D_samp_kprox,maxval=1)
D_samp_mob = pnm.imread('./paper/init-mob-samp-einstein/__final_dict_mosaic__.pbm')
pnm.imsave('einstein-init-samp-mob.pbm',D_samp_mob,maxval=1)
This diff is collapsed.
......@@ -28,7 +28,7 @@ EXP=$(patsubst %.cpp,%,$(EXPSRC))
ifdef DEBUG
CFLAGS=-DDEBUG -O -Wall -g -fopenmp -march=native -mtune=native
else
CFLAGS=-O3 -pg -Wall -Wno-unused-variable -Wno-unused-parameter -fopenmp -msse3 -march=native -mtune=native
CFLAGS=-O3 -pg -Wall -Wno-unused-variable -Wno-unused-parameter -fopenmp -march=native -mtune=native
endif
CFLAGS+=-I../contrib/include
LDFLAGS=-L../contrib/lib -lgsl -lgslcblas -lm
......
/**
/**
* Adds binary memoryless noise to an input matrix.
* Parameters: input.pbm output.pbm p [q]
* p is the crossover probability; this parameter is mandatory
......@@ -15,43 +15,43 @@ const char* ifname;
const char* ofname;
int main(int argc, char** argv) {
idx_t rows,cols;
FILE* fi, *fo;
if (argc < 4) {
std::cerr << "Wrong number of parameters.\n Usage: input.pgm output.pgm p [q]" << std::endl;
}
ifname = argv[1];
fi = fopen(ifname,"r");
if (!fi) {
std::cerr << "Error opening " << ifname << " for reading." << std::endl;
return -1;
}
read_pbm_header(fi,rows,cols);
std::cout << "rows=" << rows << " cols=" << cols << std::endl;
ofname = argv[2];
fo = fopen(ofname,"w");
if (!fo) {
std::cerr << "Error opening " << ofname << " for writing." << std::endl;
return -2;
}
const double p = atof(argv[3]);
const double q = (argc == 5 ? atof(argv[4]) : p);
std::cout << "p=" << p << " q=" << q << std::endl;
binary_matrix X(rows,cols);
binary_matrix Y(rows,cols);
idx_t rows,cols;
FILE* fi, *fo;
if (argc < 4) {
std::cerr << "Wrong number of parameters.\n Usage: input.pgm output.pgm p [q]" << std::endl;
}
ifname = argv[1];
fi = fopen(ifname,"r");
if (!fi) {
std::cerr << "Error opening " << ifname << " for reading." << std::endl;
return -1;
}
read_pbm_header(fi,rows,cols);
std::cout << "rows=" << rows << " cols=" << cols << std::endl;
ofname = argv[2];
fo = fopen(ofname,"w");
if (!fo) {
std::cerr << "Error opening " << ofname << " for writing." << std::endl;
return -2;
}
const double p = atof(argv[3]);
const double q = (argc == 5 ? atof(argv[4]) : p);
std::cout << "p=" << p << " q=" << q << std::endl;
binary_matrix X(rows,cols);
binary_matrix Y(rows,cols);
read_pbm_data(fi,X);
fclose(fi);
read_pbm_data(fi,X);
fclose(fi);
for (idx_t i = 0; i < rows; i++) {
for (idx_t j = 0; j < cols; j++) {
const bool v = X.get(i,j);
Y.set( i, j, v ? get_bernoulli_sample(1-q) : get_bernoulli_sample(p));
for (idx_t i = 0; i < rows; i++) {
for (idx_t j = 0; j < cols; j++) {
const bool v = X.get(i,j);
Y.set( i, j, v ? get_bernoulli_sample(1-q) : get_bernoulli_sample(p));
}
}
}
write_pbm(Y,fo);
fclose(fo);
X.destroy();
Y.destroy();
write_pbm(Y,fo);
fclose(fo);
X.destroy();
Y.destroy();
}
......@@ -4,85 +4,85 @@
#include "intmat.h"
size_t compute_grid_size(const size_t size, const size_t width, const size_t stride, extract_t extract_type) {
// return M, the number of patches to be extracted along a dimension
// EXTRACT_EXACT: last index (li) must be < m so
// li = (M-1)*stride + width -1 <= m -1 => M = floor [ (m - width + stride) / stride ]
// EXTRACT_FULL: first index of last patch (fi) must be < m so
// fi = (M-1)*stride <= m - 1 => stride*M <= m + stride - 1 => M = floor [(m -1 + stride) / stride ]
return extract_type == EXTRACT_EXACT ? (size+stride-width)/stride : (size + stride - 1)/stride;
// return M, the number of patches to be extracted along a dimension
// EXTRACT_EXACT: last index (li) must be < m so
// li = (M-1)*stride + width -1 <= m -1 => M = floor [ (m - width + stride) / stride ]
// EXTRACT_FULL: first index of last patch (fi) must be < m so
// fi = (M-1)*stride <= m - 1 => stride*M <= m + stride - 1 => M = floor [(m -1 + stride) / stride ]
return extract_type == EXTRACT_EXACT ? (size+stride-width)/stride : (size + stride - 1)/stride;
}
void extract_patches(const binary_matrix& I,
const size_t width,
const size_t stride,
const extract_t e,
binary_matrix& X) {
const size_t M = I.get_rows();
const size_t N = I.get_cols();
const size_t mg = compute_grid_size(M,width,stride,e);
const size_t ng = compute_grid_size(N,width,stride,e);
const size_t n = mg*ng;
const size_t m = width*width;
assert(X.get_rows() == n);
assert(X.get_cols() == m);
binary_matrix P(width,width),V(1,m);
size_t li = 0;
X.clear(); // debug
for (size_t i = 0, ig = 0; ig < mg; ig++, i += stride) {
for (size_t j = 0, jg = 0; jg < ng; jg++, j += stride) {
I.copy_submatrix_to(i,i+width,j,j+width,P);
P.copy_vectorized_to(V);
X.set_row(li,V);
li++;
} // for j
} // for i
P.destroy();
V.destroy();
const size_t width,
const size_t stride,
const extract_t e,
binary_matrix& X) {
const size_t M = I.get_rows();
const size_t N = I.get_cols();
const size_t mg = compute_grid_size(M,width,stride,e);
const size_t ng = compute_grid_size(N,width,stride,e);
const size_t n = mg*ng;
const size_t m = width*width;
assert(X.get_rows() == n);
assert(X.get_cols() == m);
binary_matrix P(width,width),V(1,m);
size_t li = 0;
X.clear(); // debug
for (size_t i = 0, ig = 0; ig < mg; ig++, i += stride) {
for (size_t j = 0, jg = 0; jg < ng; jg++, j += stride) {
I.copy_submatrix_to(i,i+width,j,j+width,P);
P.copy_vectorized_to(V);
X.set_row(li,V);
li++;
} // for j
} // for i
P.destroy();
V.destroy();
}
void stitch_patches(const binary_matrix& P,
const size_t M,
const size_t N,
const size_t stride,
const extract_t e,
binary_matrix& I,
integer_matrix& A,
integer_matrix& C) {
assert(I.get_rows() == M);
assert(I.get_cols() == N);
assert(A.get_rows() == M);
assert(A.get_cols() == N);
assert(C.get_rows() == M);
assert(C.get_cols() == N);
const size_t width = (size_t) sqrt(double(P.get_cols()));
const size_t mg = compute_grid_size(M,width,stride,e);
const size_t ng = compute_grid_size(N,width,stride,e);
const size_t n = mg*ng;
assert(P.get_rows() == n);
C.clear(); // clear image
A.clear(); // clear image
size_t k = 0;
for (size_t ig = 0, i = 0; ig < mg; ++ig, i+= stride ) {
for (size_t jg = 0, j = 0; jg < ng; ++jg, j += stride) {
size_t l = 0;
for (size_t ii = 0; ii < width; ++ii) {
for (size_t jj = 0; jj < width; ++jj) {
C.inc(i+ii,j+jj);
if (P.get(k,l))
A.inc(i+ii,j+jj);
l++;
} // for ii
}// for jj
k++;
} // for j
} // for i
//
// normalization
//
for (size_t i = 0; i < M; ++i ) {
for (size_t j = 0; j < N; ++j ) {
I.set(i, j, 2*A.get(i,j) >= C.get(i,j) );
} // for j
} // for i
const size_t M,
const size_t N,
const size_t stride,
const extract_t e,
binary_matrix& I,
integer_matrix& A,
integer_matrix& C) {
assert(I.get_rows() == M);
assert(I.get_cols() == N);
assert(A.get_rows() == M);
assert(A.get_cols() == N);
assert(C.get_rows() == M);
assert(C.get_cols() == N);
const size_t width = (size_t) sqrt(double(P.get_cols()));
const size_t mg = compute_grid_size(M,width,stride,e);
const size_t ng = compute_grid_size(N,width,stride,e);
const size_t n = mg*ng;
assert(P.get_rows() == n);
C.clear(); // clear image
A.clear(); // clear image
size_t k = 0;
for (size_t ig = 0, i = 0; ig < mg; ++ig, i+= stride ) {
for (size_t jg = 0, j = 0; jg < ng; ++jg, j += stride) {
size_t l = 0;
for (size_t ii = 0; ii < width; ++ii) {
for (size_t jj = 0; jj < width; ++jj) {
C.inc(i+ii,j+jj);
if (P.get(k,l))
A.inc(i+ii,j+jj);
l++;
} // for ii
}// for jj
k++;
} // for j
} // for i
//
// normalization
//
for (size_t i = 0; i < M; ++i ) {
for (size_t j = 0; j < N; ++j ) {
I.set(i, j, 2*A.get(i,j) >= C.get(i,j) );
} // for j
} // for i
}
/**
* \file binimage.h
* \brief Handling of binary images
*/
#ifndef BINIMAGE_H
#define BINIMAGE_H
#include <stdlib.h>
......@@ -7,27 +11,27 @@
#define CCLIP(x,a,b) ( (x) > (a) ? ( (x) < (b) ? (x) : (b) ) : (a) )
typedef enum {
EXTRACT_EXACT, /// only extract patches which contain true pixels, possibly leaving bordering pixels out
EXTRACT_FULL, /// extract patches so that whole image is covered, extrapolating border pixels as needed
EXTRACT_EXACT, /// only extract patches which contain true pixels, possibly leaving bordering pixels out
EXTRACT_FULL, /// extract patches so that whole image is covered, extrapolating border pixels as needed
} extract_t;
size_t compute_grid_size(const size_t size, const size_t width, const size_t stride, extract_t extract_type);
void extract_patches(const binary_matrix& I,
const size_t width,
const size_t stride,
const extract_t e,
binary_matrix& P);
const size_t width,
const size_t stride,
const extract_t e,
binary_matrix& P);
// I must be preallocated
// I must be preallocated
void stitch_patches(const binary_matrix& P,
const size_t M,
const size_t N,
const size_t stride,
const extract_t e,
binary_matrix& I,
integer_matrix& A,
integer_matrix& C);
const size_t M,
const size_t N,
const size_t stride,
const extract_t e,
binary_matrix& I,
integer_matrix& A,
integer_matrix& C);
#endif
This diff is collapsed.
This diff is collapsed.
......@@ -3,121 +3,121 @@
#include <cstdio>
int main(int argc, char **argv) {
binary_matrix A(8,128);
std::cout << A;
A.clear();
std::cout << A;
for (idx_t i = 0 ; i < A.get_rows(); i++) {
idx_t m1 = 1UL << (i+1);
idx_t m2 = 1UL << i;
// std::cout << "i=" << i << " m1=" << std::bitset<sizeof(idx_t)*8>(m1) << "\tm2="<< std::bitset<sizeof(idx_t)*8>(m2) << std::endl;
for (idx_t j = 0 ; j < A.get_cols(); j++) {
A.set(i,j, (j & (m1-1)) & m2 ? 1 : 0);
binary_matrix A(8,128);
std::cout << A;
A.clear();
std::cout << A;
for (idx_t i = 0 ; i < A.get_rows(); i++) {
idx_t m1 = 1UL << (i+1);
idx_t m2 = 1UL << i;
// std::cout << "i=" << i << " m1=" << std::bitset<sizeof(idx_t)*8>(m1) << "\tm2="<< std::bitset<sizeof(idx_t)*8>(m2) << std::endl;
for (idx_t j = 0 ; j < A.get_cols(); j++) {
A.set(i,j, (j & (m1-1)) & m2 ? 1 : 0);
}
}
std::cout << A.get(5,0) << std::endl;
std::cout << A;
std::cout <<"Total Sum:" << A.sum() << std::endl;
std::cout <<"Total Weight:" << A.weight() << std::endl;
for (idx_t i = 0 ; i < A.get_rows(); i++) {
std::cout << "ROW " << i << ": w=" << A.row_weight(i) << " s=" << A.row_sum(i) << std::endl;
}
for (idx_t i = 0 ; i < A.get_cols(); i++) {
std::cout << "COL " << i << ": w=" << A.col_weight(i) << " s=" << A.col_sum(i) << std::endl;
}
}
std::cout << A.get(5,0) << std::endl;
std::cout << A;
std::cout <<"Total Sum:" << A.sum() << std::endl;
std::cout <<"Total Weight:" << A.weight() << std::endl;
for (idx_t i = 0 ; i < A.get_rows(); i++) {
std::cout << "ROW " << i << ": w=" << A.row_weight(i) << " s=" << A.row_sum(i) << std::endl;
}
for (idx_t i = 0 ; i < A.get_cols(); i++) {
std::cout << "COL " << i << ": w=" << A.col_weight(i) << " s=" << A.col_sum(i) << std::endl;
}
binary_matrix B(3,2);
binary_matrix C(2,3);
binary_matrix D(3,3);
B.clear();
C.clear();
D.clear();
B.set(0,0,1);
B.set(1,0,1);
// B.set(2,0,1);
B.set(0,1,1);
B.set(2,1,1);
std::cout << "B=" << B << std::endl;
C.set(0,1,1);
C.set(1,0,1);
C.set(1,2,1);
std::cout << "C=" << C << std::endl;
mul(B,false,C,false,D);
std::cout << "BC=" << D << std::endl;
mul(B,false,B,true,D);
std::cout << "BBt=" << D << std::endl;
mul(C,true,C,false,D);
std::cout << "CtC=" << D << std::endl;
A = D.get_vectorized();
std::cout << "==== D.get_vectorized() =====\n" << A << std::endl;
binary_matrix B(3,2);
binary_matrix C(2,3);
binary_matrix D(3,3);
B.clear();
C.clear();
D.clear();
B.set(0,0,1);
B.set(1,0,1);
// B.set(2,0,1);
B.set(0,1,1);
B.set(2,1,1);
std::cout << "B=" << B << std::endl;
C.set(0,1,1);
C.set(1,0,1);
C.set(1,2,1);
std::cout << "C=" << C << std::endl;
mul(B,false,C,false,D);
std::cout << "BC=" << D << std::endl;
mul(B,false,B,true,D);
std::cout << "BBt=" << D << std::endl;
mul(C,true,C,false,D);
std::cout << "CtC=" << D << std::endl;
A = D.get_vectorized();
std::cout << "==== D.get_vectorized() =====\n" << A << std::endl;
idx_t rows,cols;
FILE* fimg;
fimg = fopen("data/camera.pbm","r");
if (!fimg) return -1;
read_pbm_header(fimg,rows,cols);
std::cout << "rows=" << rows << " cols=" << cols << std::endl;
binary_matrix I(rows,cols);
read_pbm_data(fimg,I);
fclose(fimg);
fimg = fopen("copy.pbm","w");
if (!fimg) return -2;
write_pbm(I,fimg);
fclose(fimg);
std::cout << "==== ORIGINAL =====\n" << std::endl;
std::cout << std::endl << I << std::endl;
binary_matrix Iref;
Iref = I.get_row(30);
std::cout << "==== ROW 30 =====\n" << Iref << std::endl;
Iref = I.get_col(30);
std::cout << "==== COL 30 =====\n" << Iref << std::endl;
idx_t rows,cols;
FILE* fimg;
fimg = fopen("data/camera.pbm","r");
if (!fimg) return -1;
read_pbm_header(fimg,rows,cols);
std::cout << "rows=" << rows << " cols=" << cols << std::endl;
binary_matrix I(rows,cols);
read_pbm_data(fimg,I);
fclose(fimg);
fimg = fopen("copy.pbm","w");
if (!fimg) return -2;
write_pbm(I,fimg);
fclose(fimg);
std::cout << "==== ORIGINAL =====\n" << std::endl;
std::cout << std::endl << I << std::endl;
binary_matrix Iref;
Iref = I.get_row(30);
std::cout << "==== ROW 30 =====\n" << Iref << std::endl;
Iref = I.get_col(30);
std::cout << "==== COL 30 =====\n" << Iref << std::endl;
Iref = I.get_submatrix(13,40,40,75);
std::cout << "==== I[13:40,40:75] =====\n" << Iref << std::endl;
Iref = I.get_submatrix(13,40,40,75);
std::cout << "==== I[13:40,40:75] =====\n" << Iref << std::endl;
Iref.set();
I.set_submatrix(13,40,Iref);
std::cout << "==== I[13:40,40:75] =====\n" << I << std::endl;
Iref.set();
I.set_submatrix(13,40,Iref);
std::cout << "==== I[13:40,40:75] =====\n" << I << std::endl;
binary_matrix I2;
for (idx_t i = 0; i < I.get_rows(); ++i) {
Iref = I.get_row(i);
I2 = I.get_row(I.get_rows()-i);
I.set_row(i,I2);
I.set_row(I.get_rows()-i,Iref);
}
I2.destroy();
Iref.destroy();
I.destroy();
binary_matrix I2;
for (idx_t i = 0; i < I.get_rows(); ++i) {
Iref = I.get_row(i);
I2 = I.get_row(I.get_rows()-i);
I.set_row(i,I2);
I.set_row(I.get_rows()-i,Iref);
}
I2.destroy();
Iref.destroy();
I.destroy();
A.destroy();
B.destroy();
C.destroy();
D.destroy();
A.destroy();
B.destroy();
C.destroy();
D.destroy();
#if 0
OK ref(orig);
OK ref_block(orig,i0,i1,j0,j1);
OK aligned();
OK clear();
OK set();
OK weight();
OK row_weight(i);
OK col_weight(j);
OK sum();
OK row_sum(i);
OK col_sum(idx_t j);
OK shallow_copy(orig);
OK ref_col(orig,j);
OK ref_row(orig,i);
OK full_copy(orig);
// =
add(A, B, C);
eland(A, B, C);
elor(A, B, C);
elnot(A, B);
mul(A, At, B, Bt, C);
OK ref(orig);
OK ref_block(orig,i0,i1,j0,j1);
OK aligned();
OK clear();
OK set();
OK weight();
OK row_weight(i);
OK col_weight(j);
OK sum();
OK row_sum(i);
OK col_sum(idx_t j);
OK shallow_copy(orig);
OK ref_col(orig,j);
OK ref_row(orig,i);
OK full_copy(orig);
// =
add(A, B, C);
eland(A, B, C);
elor(A, B, C);
elnot(A, B);
mul(A, At, B, Bt, C);
#endif
return 0;
return 0;
}
#include <cstdio>
#include <cstdio>
#include "pbm.h"
#include "pnm.h"
const char * fname = "data/img/camera.pgm";
int main(int argc, char** argv) {
int type,rows,cols,maxval;
FILE* fimg;
char ofname[128];
if (argc > 1) { fname = argv[1]; }
fimg = fopen(fname,"r");
if (!fimg) {
std::cerr << "Error opening " << fname << " for reading." << std::endl;
return -1;
}