Skip to content
Open

Hi #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

#README
# Compile only daisy as a library.
# do not compile the binary because third party libraries are required
# such as png zlib and jpeg

project(daisy)

IF (UNIX OR APPLE)
check_symbol_exists(mmap64 "sys/mman.h" HAVE_MMAP64)
ENDIF ()

if(${HAVE_MMAP64})
message("System has large file support.")
add_definitions(-DHAVE_LARGE_FILE_SUPPORT)
else()
message("System hasn't large file support.")
endif()

#Detect OpenMP
FIND_PACKAGE(OpenMP)
if (OPENMP_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
option(USE_OPENMP "Use OpenMP for parallelization" ON)
add_definitions(-DUSE_OPENMP)
else(OPENMP_FOUND)
option(USE_OPENMP "Use OpenMP for parallelization" OFF)
endif (OPENMP_FOUND)

include_directories(include)

# Make the headers appear in IDEs.
file(GLOB daisy_hdrs include/kutility/*.h include/daisy/*.h)

set(daisy_srcs
src/daisy.cpp
src/corecv.cpp
src/image_io_bmp.cpp
src/image_io_pnm.cpp
src/image_io_png.cpp
src/image_io_jpeg.cpp
src/image_manipulation.cpp
src/progress_bar.cpp
src/general.cpp
src/interaction.cpp
)

add_library(daisy ${daisy_srcs} ${daisy_hdrs})

ADD_EXECUTABLE(main_daisy src/main.cpp)
TARGET_LINK_LIBRARIES(main_daisy daisy)

23 changes: 3 additions & 20 deletions include/kutility/convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,11 @@

namespace kutility
{
inline void convolve_sym( float* image, int h, int w, float* kernel, int ksize, float* out=NULL )
template<class T>
inline void convolve_sym( T* image, int h, int w, T* kernel, int ksize, T* out=NULL )
{
if( out == NULL ) out = image;
else memcpy( out, image, sizeof(float)*h*w );

if( h == 240 && w == 320 ) { convolve_sym_(out, 240, 320, kernel, ksize); return; }
if( h == 480 && w == 640 ) { convolve_sym_(out, 480, 640, kernel, ksize); return; }
if( h == 512 && w == 512 ) { convolve_sym_(out, 512, 512, kernel, ksize); return; }
if( h == 512 && w == 768 ) { convolve_sym_(out, 512, 768, kernel, ksize); return; }
if( h == 600 && w == 800 ) { convolve_sym_(out, 600, 800, kernel, ksize); return; }
if( h == 768 && w == 1024 ) { convolve_sym_(out, 768, 1024, kernel, ksize); return; }
if( h == 1024 && w == 768 ) { convolve_sym_(out, 1024, 768, kernel, ksize); return; }
if( h == 256 && w == 256 ) { convolve_sym_(out, 256, 256, kernel, ksize); return; }
if( h == 128 && w == 128 ) { convolve_sym_(out, 128, 128, kernel, ksize); return; }
if( h == 128 && w == 192 ) { convolve_sym_(out, 128, 192, kernel, ksize); return; }
cout<<"[convolve_sym] insert this h,w to unrolling list: "<<h<<" "<<w<<endl;
convolve_sym_(out, h, w, kernel, ksize);
}
inline void convolve_sym( double* image, int h, int w, double* kernel, int ksize, double* out=NULL )
{
if( out == NULL ) out = image;
else memcpy( out, image, sizeof(double)*h*w );
else memcpy( out, image, sizeof(T)*h*w );

if( h == 240 && w == 320 ) { convolve_sym_(out, 240, 320, kernel, ksize); return; }
if( h == 480 && w == 640 ) { convolve_sym_(out, 480, 640, kernel, ksize); return; }
Expand Down
8 changes: 4 additions & 4 deletions include/kutility/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,9 @@ namespace kutility

inline bool is_number( std::string str )
{
int len=str.length();
size_t len=str.length();

for( int i=0; i<len; i++)
for( size_t i=0; i<len; i++)
{
if( is_digit(str[i]) || str[i] == '.' || str[i] == '-' )
continue;
Expand Down Expand Up @@ -607,9 +607,9 @@ namespace kutility

inline bool is_integer( std::string str )
{
int len=str.length();
size_t len=str.length();

for( int i=0; i<len; i++)
for( size_t i=0; i<len; i++)
{
if( is_digit(str[i]) || str[i] == '-' )
continue;
Expand Down
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int main( int argc, char **argv )
double yy, xx;
int ori;
string outname = filename;
int rand_samples[N*2];
std::vector<int> rand_samples(N*2, 0);
for( int i=0; i<N;i++) {
rand_samples[2*i]=rand()%(h-1)+0.4;
rand_samples[2*i+1]=rand()%(w-1)+0.4;
Expand All @@ -271,7 +271,9 @@ int main( int argc, char **argv )
break;
case SAVE_SINGLE:
fname = filename;
fname = fname + "_y=" + itoa(opy,buffer,10) + "_x=" + itoa(opx,buffer,10) + "_o=" + itoa(opo,buffer,10) + ".desc";
fname = fname + "_y=" + kutility::itoa(opy,buffer,10) + "_x="
+ kutility::itoa(opx,buffer,10)
+ "_o=" + kutility::itoa(opo,buffer,10) + ".desc";
desc->get_descriptor(opy,opx,opo,thor);
save( fname, thor, desc->grid_point_number(), histq );
break;
Expand Down