diff options
author | scuri <scuri> | 2009-06-26 17:14:56 +0000 |
---|---|---|
committer | scuri <scuri> | 2009-06-26 17:14:56 +0000 |
commit | 193cd3427108bd127e09f391f7fe51f6b62590e9 (patch) | |
tree | 7dfd83dec634c15f87f578266f6fdb0df046613a /html/download | |
parent | 734afa90c3dda1232e9490d08346be4f2ffefec1 (diff) |
*** empty log message ***
Diffstat (limited to 'html/download')
-rw-r--r-- | html/download/glut_capture.c | 412 | ||||
-rw-r--r-- | html/download/im_copy.cpp | 120 | ||||
-rw-r--r-- | html/download/im_info.cpp | 203 | ||||
-rw-r--r-- | html/download/im_view.c | 177 | ||||
-rw-r--r-- | html/download/im_view.zip | bin | 2083 -> 2617 bytes | |||
-rw-r--r-- | html/download/proc_fourier.cpp | 154 | ||||
-rw-r--r-- | html/download/samples_imlua5.tar.gz | bin | 30150 -> 32944 bytes | |||
-rw-r--r-- | html/download/samples_imlua5.zip | bin | 34315 -> 37436 bytes |
8 files changed, 0 insertions, 1066 deletions
diff --git a/html/download/glut_capture.c b/html/download/glut_capture.c deleted file mode 100644 index e8e2620..0000000 --- a/html/download/glut_capture.c +++ /dev/null @@ -1,412 +0,0 @@ -/* GLUT Capture Sample - - Uses GLUT for user interface - OpenGL for drawing - IM for image I/O and capture - - Needs "glut32.lib", "vfw32.lib", "strmiids.lib", - "im.lib", "im_capture.lib", "im_avi.lib" and "im_process.lib". - - Control Keys: - - <Esc> - Terminates - <Space> - Activates/Deactivates the capturing. - <F1>, <F2> , <F3>, etc - Shows capture configuration dialogs, in general 2, but can have more. - <v> - Starts to save every frame in an AVI file. - <b> - Process a background image using an average of N frames. - <s> - Saves the background image in a BMP file. - <1>, <2>, etc - Activates an processing operation. - Only operation 1 is working, it subtracts the background image if one was created. - <0> - Deactivates all the processing operations. - - ATENTION: These keys works at the GLUT window. - But the text input in done at the console window. - Check the correct window focus before typing keys. -*/ - -#include <stdio.h> -#include <time.h> -#include <stdlib.h> -#include <memory.h> - -#include <GL/glut.h> -#include <im.h> -#include <im_capture.h> -#include <im_image.h> -#include <im_convert.h> -#include <im_process.h> -#include <im_format_avi.h> -#include <im_util.h> - - -/* Global Variables */ -imVideoCapture* myVideoCap; /* capture control */ -imImage* image = NULL; /* capture buffer */ -unsigned char* gl_data = NULL; /* opengl display buffer */ - -char video_filename[512] = ""; -imFile* video_file = NULL; - -imImage* back_image = NULL; /* background image */ -imImage* back_acum = NULL; /* aux image for background image calculation */ -int back_count = 0; /* number of images to average */ -int back_index = 0; /* average image counter */ - -int user_key[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - -static void SimpleBackSub(imbyte *map, imbyte *back_map, int count, float tol) -{ - int i; - for (i = 0; i < count; i++) - { - int diff = map[i] - back_map[i]; - if (diff < 0) diff = -diff; - - if(diff <= tol) - map[i] = 0; - } -} - -static float tol = 10; /* you should use some key to change this */ - -void capture_process(int* user_key, imImage* image, imImage* back_image) -{ - if (user_key[0] && back_image) /* '1' */ - { - int i; - for (i = 0; i < image->depth; i++) /* notice that here depth is always 3 */ - { - SimpleBackSub((imbyte*)image->data[i], (imbyte*)back_image->data[i], image->count, tol); - } - } - - /***** call other operations here ******/ -} - - -/* Aux to draw a number in the display */ -void display_number(int num) -{ - int i; - char msg[30]; - sprintf(msg,"%4d", num); - glColor3f(1.0f,0.0f,0.0f); - glRasterPos2f(10.f,10.f); - for(i = 0; msg[i]; i++) - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, msg[i]); -} - -/* GLUT display callback */ -/* called everytime the window needs to be updated */ -void display(void) -{ - if (!image) - return; - - /* Draws the captured image at (0,0) */ - glRasterPos2f(0.f, 0.f); - glDrawPixels(image->width, image->height, GL_RGB, GL_UNSIGNED_BYTE, gl_data); - - glutSwapBuffers(); -} - - -/* GLUT reshape callback */ -/* called everytime the window changes its size */ -void reshape(int w, int h) -{ - glViewport(0, 0, w, h); -} - - -/* GLUT idle callback */ -/* called when there is no events to be processed */ -void idle(void) -{ - if (imVideoCaptureLive(myVideoCap, -1)) - { - imVideoCaptureFrame(myVideoCap, image->data[0], IM_RGB, 1000); - - if (back_image && back_index < back_count) - { - /* calculating the background image */ - - imProcessUnArithmeticOp(image, back_acum, IM_UN_INC); /* back_image += image */ - back_index++; - - if (back_index == back_count) /* last sum, divide by N */ - { - imProcessArithmeticConstOp(back_acum, (float)back_count, back_image, IM_BIN_DIV); - printf("Background image updated.\n"); - } - } - else - { - /* call some processing */ - capture_process(user_key, image, back_image); - - if (video_file) - imFileWriteImageData(video_file, image->data[0]); - } - - imConvertPacking(image->data[0], gl_data, image->width, image->height, image->depth, image->data_type, 0); - display(); - } -} - - -/* OpenGL initialization */ -void glinit(void) -{ - if (!image) - return; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D (0.0, (GLdouble)image->width, 0.0, (GLdouble)image->height); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - - -/* updates the capture image size and display buffer size */ -void updatebuffer(void) -{ - int width, height; - - /* retrieve the image size */ - imVideoCaptureGetImageSize(myVideoCap, &width, &height); - - if (width != image->width || height != image->height) - { - /* fix the buffer size */ - imImageReshape(image, width, height); - gl_data = realloc(gl_data, image->size); - - /* fix the window size */ - glutReshapeWindow(image->width, image->height); - - /* re-inititalizes the OpenGL */ - glinit(); - } -} - - -/* GLUT function key callback */ -/* called everytime a function key is pressed */ -void parsefunckey(int key, int x, int y) -{ - switch (key) { - case GLUT_KEY_F1: /* F1, F2, F.. = shows the capture configuration dialogs */ - case GLUT_KEY_F2: - case GLUT_KEY_F3: - case GLUT_KEY_F4: - case GLUT_KEY_F5: - case GLUT_KEY_F6: - case GLUT_KEY_F7: - case GLUT_KEY_F8: - imVideoCaptureLive(myVideoCap, 0); /* deactivate the capture before calling the dialog */ - imVideoCaptureShowDialog(myVideoCap, key - GLUT_KEY_F1, NULL); - updatebuffer(); - imVideoCaptureLive(myVideoCap, 1); - break; - } -} - -/* GLUT key callback */ -/* called everytime an ASCII key is pressed */ -void parsekey(unsigned char key, int x, int y) -{ - int error, index; - switch (key) { - case 27: /* Esc = terminates */ - printf("\nTerminating...\n"); - imVideoCaptureDisconnect(myVideoCap); - imVideoCaptureDestroy(myVideoCap); - imImageDestroy(image); - if (video_file) - { - imFileClose(video_file); - printf("AVI file created.\n"); - } - free(gl_data); - exit(1); - case ' ': /* Space = activates/deactivates the capturing */ - if (imVideoCaptureLive(myVideoCap, -1)) - imVideoCaptureLive(myVideoCap, 0); - else - imVideoCaptureLive(myVideoCap, 1); - break; - case 'v': - if (video_file) - { - imFileClose(video_file); - printf("AVI file created.\n"); - video_file = NULL; - break; - } - printf("Enter the AVI file name:\n >"); - scanf("%s", video_filename); - video_file = imFileNew(video_filename, "AVI", &error); - if (!video_file) - printf("Error creating video file.\n"); - else - { - imFileSetInfo(video_file, "CUSTOM"); /* shows the compression options dialog */ - imFileWriteImageInfo(video_file, image->width, image->height, IM_RGB, IM_BYTE); - } - break; - case 'b': - if (back_image) - { - imImageDestroy(back_image); - imImageDestroy(back_acum); - } - printf("Enter the number of images to average:\n >"); - scanf("%d", &back_count); - back_acum = imImageCreate(image->width, image->height, IM_RGB, IM_USHORT); - back_image = imImageClone(image); - back_index = 0; - break; - case 's': - if (back_image) - { - char filename[512]; - imFile* ifile; - printf("Enter the BMP file name:\n >"); - scanf("%s", filename); - ifile = imFileNew(filename, "BMP", &error); - if (!ifile) { - printf("Error creating image file.\n"); return; - } - imFileSaveImage(ifile, back_image); - imFileClose(ifile); - printf("BMP file created.\n"); - } - break; - case '0': - memset(user_key, 0, 9*sizeof(int)); - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - index = key - '1'; - user_key[index] = user_key[index]? 0: 1; /* switch state */ - if (user_key[index]) - printf("Processing %c activated. \n", key); - else - printf("Processing %c deactivated. \n", key); - return; - default: - glutPostRedisplay(); - return; - } -} - - -/* Returns a capture device */ -int getcapture(void) -{ - int i; - int cap_count = imVideoCaptureDeviceCount(); - if (cap_count == 1) /* only one device */ - return 0; - - printf("Enter the capture device number to use:\n"); - for (i = 0; i < cap_count; i++) - { - printf(" %s\n", imVideoCaptureDeviceDesc(i)); - } - - printf(" > "); - scanf("%d", &i); - if (i < 0 || i >= cap_count) - return 0; - - return i; -} - - -/* Initializes the capture device */ -int initcapture(void) -{ - int width, height; - - /* creates an IM video capture manager */ - myVideoCap = imVideoCaptureCreate(); - if (!myVideoCap) { - printf("No capture device found.\n"); return 0; - } - - /* conects the device */ - if (!imVideoCaptureConnect(myVideoCap, getcapture())) { - imVideoCaptureDestroy(myVideoCap); - printf("Can not connect to capture device.\n"); return 0; - } - - if (!imVideoCaptureLive(myVideoCap, 1)) { - imVideoCaptureDisconnect(myVideoCap); - imVideoCaptureDestroy(myVideoCap); - printf("Can not activate capturing.\n"); return 0; - } - - /* retrieve the image size */ - imVideoCaptureGetImageSize(myVideoCap, &width, &height); - - /* alocates the buffers */ - image = imImageCreate(width, height, IM_RGB, IM_BYTE); - gl_data = malloc(image->size); - - return 1; -} - - -int main(int argc, char* argv[]) -{ - printf("GLUT Capture\n"); - printf(" <Esc> - Terminates.\n" - " <Space> - Activates/Deactivates the capturing.\n" - " <F1>, <F2> , <F3>, ... - Shows capture configuration dialogs.\n" - " <v> - Starts to save every frame in an AVI file.\n" - " <b> - Process a background image using an average of N frames.\n" - " <s> - Saves the background image in a BMP file.\n" - " <1>, <2>, ... - Activates an processing operation.\n" - " <0> - Deactivates all the processing operations.\n\n"); - - /* Initializes the capture device */ - if (!initcapture()) - return 1; - - imFormatRegisterAVI(); - - /* GLUT initialization */ - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); - glutInitWindowPosition(100, 100); - glutInitWindowSize(image->width, image->height); - glutCreateWindow("GLUT Capture"); - - glClearColor(0., 0., 0., 1.0); /* window background */ - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* data alignment is 1 */ - - /* register GLUT callbacks */ - glutDisplayFunc(display); - glutReshapeFunc(reshape); - glutKeyboardFunc(parsekey); - glutSpecialFunc(parsefunckey); - glutIdleFunc(idle); - - /* OpenGL initialization */ - glinit(); - - /* GLUT message loop */ - glutMainLoop(); - - return 0; -} diff --git a/html/download/im_copy.cpp b/html/download/im_copy.cpp deleted file mode 100644 index cf0e0d5..0000000 --- a/html/download/im_copy.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* IM 3 sample that copies an image from one file to another. - It is good to test the file formats read and write. - If the destiny does not supports the input image it aborts and returns an error. - - Needs "im.lib". - - Usage: im_copy <input_file_name> <output_file_name> [<output_format>] - - Example: im_copy test.tif test_proc.tif -*/ - -#include <im.h> -#include <im_util.h> - -#include <stdio.h> -#include <stdlib.h> - - -void PrintError(int error) -{ - switch (error) - { - case IM_ERR_OPEN: - printf("Error Opening File.\n"); - break; - case IM_ERR_MEM: - printf("Insuficient memory.\n"); - break; - case IM_ERR_ACCESS: - printf("Error Accessing File.\n"); - break; - case IM_ERR_DATA: - printf("Image type not Suported.\n"); - break; - case IM_ERR_FORMAT: - printf("Invalid Format.\n"); - break; - case IM_ERR_COMPRESS: - printf("Invalid or unsupported compression.\n"); - break; - default: - printf("Unknown Error.\n"); - } -} - -int main(int argc, char* argv[]) -{ - if (argc < 3) - { - printf("Invalid number of arguments.\n"); - return 0; - } - - void* data = NULL; - imFile* ifile = NULL; - imFile* ofile = NULL; - - int error; - ifile = imFileOpen(argv[1], &error); - if (!ifile) - goto man_error; - - char format[10]; - char compression[20]; - int image_count; - imFileGetInfo(ifile, format, compression, &image_count); - - ofile = imFileNew(argv[2], argv[3]? argv[3]: format, &error); - if (!ofile) - goto man_error; - - if (!argv[3]) - imFileSetInfo(ofile, compression); - - for (int i = 0; i < image_count; i++) - { - int width, height, color_mode, data_type; - error = imFileReadImageInfo(ifile, i, &width, &height, &color_mode, &data_type); - if (error != IM_ERR_NONE) - goto man_error; - - data = malloc(imImageDataSize(width, height, color_mode, data_type)); - - error = imFileReadImageData(ifile, data, 0, -1); - if (error != IM_ERR_NONE) - goto man_error; - - char* attrib_list[50]; - int attrib_list_count; - imFileGetAttributeList(ifile, attrib_list, &attrib_list_count); - - for (int a = 0; a < attrib_list_count; a++) - { - int attrib_data_type, attrib_count; - const void* attrib_data = imFileGetAttribute(ifile, attrib_list[a], &attrib_data_type, &attrib_count); - imFileSetAttribute(ofile, attrib_list[a], attrib_data_type, attrib_count, attrib_data); - } - - error = imFileWriteImageInfo(ofile, width, height, color_mode, data_type); - if (error != IM_ERR_NONE) - goto man_error; - - error = imFileWriteImageData(ofile, data); - if (error != IM_ERR_NONE) - goto man_error; - } - - free(data); - imFileClose(ifile); - imFileClose(ofile); - - return 1; - -man_error: - PrintError(error); - if (data) free(data); - if (ifile) imFileClose(ifile); - if (ofile) imFileClose(ofile); - return 0; -} diff --git a/html/download/im_info.cpp b/html/download/im_info.cpp deleted file mode 100644 index f9106fd..0000000 --- a/html/download/im_info.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* IM 3 sample that returns information about a file. - - Needs "im.lib". - - Usage: im_info <file_name> - - Example: im_info test.tif -*/ - -#include <im.h> -#include <im_util.h> -#include <im_binfile.h> - -#include <stdio.h> - -void PrintError(int error) -{ - switch (error) - { - case IM_ERR_OPEN: - printf("Error Opening File.\n"); - break; - case IM_ERR_MEM: - printf("Insuficient memory.\n"); - break; - case IM_ERR_ACCESS: - printf("Error Accessing File.\n"); - break; - case IM_ERR_DATA: - printf("Image type not Suported.\n"); - break; - case IM_ERR_FORMAT: - printf("Invalid Format.\n"); - break; - case IM_ERR_COMPRESS: - printf("Invalid or unsupported compression.\n"); - break; - default: - printf("Unknown Error.\n"); - } -} - -int FindZero(imbyte* data, int count) -{ - for (int i = 0; i < count; i++) - { - if (data[i] == 0) - return 1; - } - return 0; -} - -char* AttribData2Str(const void* data, int data_type) -{ - static char data_str[50] = ""; - - switch(data_type) - { - case IM_BYTE: - sprintf(data_str, "%3d", (int)(*((imbyte*)data))); - break; - case IM_USHORT: - sprintf(data_str, "%5d", (int)(*((imushort*)data))); - break; - case IM_INT: - sprintf(data_str, "%5d", *((int*)data)); - break; - case IM_FLOAT: - sprintf(data_str, "%5.2f", (double)(*((float*)data))); - break; - case IM_CFLOAT: - { - float *c = (float*)data; - sprintf(data_str, "%5.2g, %5.2f", (double)*c, (double)*(c+1)); - } - break; - } - - return data_str; -} - -char* GetSizeDesc(double *size) -{ - char* size_desc; - - if (*size < 1024) - size_desc = "b"; - else - { - *size /= 1024; - - if (*size < 1024) - size_desc = "Kb"; - else - { - *size /= 1024; - size_desc = "Mb"; - } - } - - return size_desc; -} - -unsigned long FileSize(const char* file_name) -{ - imBinFile* bfile = imBinFileOpen(file_name); - if (!bfile) return 0; - - unsigned long file_size = imBinFileSize(bfile); - - imBinFileClose(bfile); - return file_size; -} - -void PrintImageInfo(const char* file_name) -{ - printf("IM Info\n"); - printf(" File Name:\n %s\n", file_name); - - int error; - imFile* ifile = imFileOpen(file_name, &error); - if (!ifile) - { - PrintError(error); - return; - } - - double file_size = FileSize(file_name); - printf(" File Size: %.2f %s\n", file_size, GetSizeDesc(&file_size)); - - char format[10]; - char compression[20]; - int image_count; - imFileGetInfo(ifile, format, compression, &image_count); - - char format_desc[50]; - imFormatInfo(format, format_desc, NULL, NULL); - printf(" Format: %s - %s\n", format, format_desc); - printf(" Compression: %s\n", compression); - printf(" Image Count: %d\n", image_count); - - for (int i = 0; i < image_count; i++) - { - int width, height, color_mode, data_type; - - error = imFileReadImageInfo(ifile, i, &width, &height, &color_mode, &data_type); - if (error != IM_ERR_NONE) - { - PrintError(error); - imFileClose(ifile); - return; - } - - printf(" Image #%d\n", i); - printf(" Width: %d\n", width); - printf(" Height: %d\n", height); - printf(" Color Space: %s\n", imColorModeSpaceName(color_mode)); - printf(" Has Alpha: %s\n", imColorModeHasAlpha(color_mode)? "Yes": "No"); - printf(" Is Packed: %s\n", imColorModeIsPacked(color_mode)? "Yes": "No"); - printf(" Is Top Down: %s\n", imColorModeIsTopDown(color_mode)? "Yes": "No"); - printf(" Data Type: %s\n", imDataTypeName(data_type)); - - double image_size = imImageDataSize(width, height, color_mode, data_type); - printf(" Data Size: %.2f %s\n", image_size, GetSizeDesc(&image_size)); - - char* attrib_list[50]; // should be dynamic allocated - int attrib_list_count; - imFileGetAttributeList(ifile, attrib_list, &attrib_list_count); - - for (int a = 0; a < attrib_list_count; a++) - { - if (a == 0) - printf(" Attributes:\n"); - - int attrib_data_type, attrib_count; - const void* attrib_data = imFileGetAttribute(ifile, attrib_list[a], &attrib_data_type, &attrib_count); - - if (attrib_count == 1) - printf(" %s: %s\n", attrib_list[a], AttribData2Str(attrib_data, attrib_data_type)); - else if (attrib_data_type == IM_BYTE && FindZero((imbyte*)attrib_data, attrib_count)) - printf(" %s: %s\n", attrib_list[a], attrib_data); - else - printf(" %s: %s %s ...\n", attrib_list[a], AttribData2Str(attrib_data, attrib_data_type), AttribData2Str((imbyte*)attrib_data + imDataTypeSize(attrib_data_type), attrib_data_type)); - } - } - - imFileClose(ifile); -} - -#include <windows.h> - -int main(int argc, char* argv[]) -{ - if (argc < 2) - { - printf("Invalid number of arguments.\n"); - return 0; - } - - PrintImageInfo(argv[1]); - - return 1; -} diff --git a/html/download/im_view.c b/html/download/im_view.c deleted file mode 100644 index d9e2b72..0000000 --- a/html/download/im_view.c +++ /dev/null @@ -1,177 +0,0 @@ -/* IM 3 sample that shows an image. - - Needs "im.lib", "iup.lib", "cd.lib" and "cdiup.lib". - - Usage: im_view <file_name> - - Example: im_view test.tif - - Click on image to open another file. -*/ - -#include <iup.h> -#include <cd.h> -#include <cdiup.h> -#include <im.h> -#include <im_image.h> - -#include <stdio.h> -#include <string.h> - -static int disable_repaint = 0; /* used to optimize repaint, while opening a new file */ - -static void PrintError(int error) -{ - switch (error) - { - case IM_ERR_OPEN: - printf("Error Opening File.\n"); - break; - case IM_ERR_MEM: - printf("Insuficient memory.\n"); - break; - case IM_ERR_ACCESS: - printf("Error Accessing File.\n"); - break; - case IM_ERR_DATA: - printf("Image type not Suported.\n"); - break; - case IM_ERR_FORMAT: - printf("Invalid Format.\n"); - break; - case IM_ERR_COMPRESS: - printf("Invalid or unsupported compression.\n"); - break; - default: - printf("Unknown Error.\n"); - } -} - -static int cbRepaint(Ihandle* iup_canvas) -{ - cdCanvas* cd_canvas = (cdCanvas*)IupGetAttribute(iup_canvas, "cdCanvas"); - imImage* image = (imImage*)IupGetAttribute(iup_canvas, "imImage"); - - if (!cd_canvas || disable_repaint) - return IUP_DEFAULT; - - cdActivate(cd_canvas); - cdClear(); - - if (!image) - return IUP_DEFAULT; - - imcdCanvasPutImage(cd_canvas, image, 0, 0, image->width, image->height, 0, 0, 0, 0); - - cdFlush(); - - return IUP_DEFAULT; -} - -static void ShowImage(char* file_name, Ihandle* iup_dialog) -{ - int error; - imImage* image = (imImage*)IupGetAttribute(iup_dialog, "imImage"); - if (image) imImageDestroy(image); - IupSetAttribute(iup_dialog, "imImage", NULL); - - image = imFileImageLoadBitmap(file_name, 0, &error); - if (!image) - { - PrintError(error); - return; - } - - IupSetAttribute(iup_dialog, "imImage", (char*)image); - IupStoreAttribute(iup_dialog, "TITLE", file_name); - - cbRepaint(iup_dialog); /* we can do this because canvas inherit attributes from the dialog */ -} - -static int cbButton(Ihandle* iup_canvas, int but, int pressed) -{ - char file_name[200] = "*.*"; - - if (but != IUP_BUTTON1 || !pressed) - return IUP_DEFAULT; - - disable_repaint = 1; - if (IupGetFile(file_name) != 0) - { - disable_repaint = 0; - return IUP_DEFAULT; - } - - disable_repaint = 0; - ShowImage(file_name, IupGetDialog(iup_canvas)); - - return IUP_DEFAULT; -} - -static int cbClose(Ihandle* iup_dialog) -{ - cdCanvas* cd_canvas = (cdCanvas*)IupGetAttribute(iup_dialog, "cdCanvas"); - imImage* image = (imImage*)IupGetAttribute(iup_dialog, "imImage"); - - if (cd_canvas) cdKillCanvas(cd_canvas); - if (image) imImageDestroy(image); - - return IUP_CLOSE; -} - -static Ihandle* CreateDialog(void) -{ - Ihandle *iup_dialog; - Ihandle *iup_canvas; - cdCanvas* cd_canvas; - - iup_canvas = IupCanvas("do_nothing"); - IupSetAttribute(iup_canvas, IUP_BUTTON_CB, "cbButton"); - IupSetAttribute(iup_canvas, IUP_ACTION, "cbRepaint"); - - iup_dialog = IupDialog(iup_canvas); - IupSetAttribute(iup_dialog, IUP_CLOSE_CB, "cbClose"); - IupSetAttribute(iup_dialog, IUP_SIZE, "HALFxHALF"); - - IupSetFunction("cbRepaint", (Icallback)cbRepaint); - IupSetFunction("cbButton", (Icallback)cbButton); - IupSetFunction("cbClose", (Icallback)cbClose); - - IupMap(iup_dialog); - - cd_canvas = cdCreateCanvas(CD_IUP, iup_canvas); - IupSetAttribute(iup_dialog, "cdCanvas", (char*)cd_canvas); - - return iup_dialog; -} - -int main(int argc, char* argv[]) -{ - Ihandle* dlg; - - IupOpen(); - - dlg = CreateDialog(); - - IupShow(dlg); - - /* Try to get a file name from the command line. */ - if (argc > 1) - { - ShowImage(argv[1], dlg); - } - else - { - char file_name[1024] = "*.*"; - if (IupGetFile(file_name) == 0) - { - ShowImage(file_name, dlg); - } - } - - IupMainLoop(); - IupDestroy(dlg); - IupClose(); - - return 1; -} diff --git a/html/download/im_view.zip b/html/download/im_view.zip Binary files differindex 5491add..e02233e 100644 --- a/html/download/im_view.zip +++ b/html/download/im_view.zip diff --git a/html/download/proc_fourier.cpp b/html/download/proc_fourier.cpp deleted file mode 100644 index 48baa60..0000000 --- a/html/download/proc_fourier.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* IM 3 sample that calculates the Forward FFT, - process in the domain frequency, - and calculates the Inverse FFT. - - Needs "im.lib" and "im_fftw.lib". - - Usage: proc_fourier <input_file_name> <output_file_name> <output_format> - - Example: proc_fourier test.tif test_proc.tif TIFF -*/ - -#include <im.h> -#include <im_image.h> -#include <im_process.h> -#include <im_convert.h> -#include <im_complex.h> - -#include <stdio.h> - -void FreqDomainProc(imImage* fft_image) -{ - // a loop for all the color planes - for (int d = 0; d < fft_image->depth; d++) - { - imcfloat* data = (imcfloat*)fft_image->data[d]; - - for (int y = 0; y < fft_image->height; y++) - { - for (int x = 0; x < fft_image->width; x++) - { - // Do something - // Remeber that the zero frequency is at the center - int offset = y * fft_image->width + x; - - data[offset].imag = 0; // notice in the result that the imaginary part has an important hole. - } - } - } -} - -void PrintError(int error) -{ - switch (error) - { - case IM_ERR_OPEN: - printf("Error Opening File.\n"); - break; - case IM_ERR_MEM: - printf("Insuficient memory.\n"); - break; - case IM_ERR_ACCESS: - printf("Error Accessing File.\n"); - break; - case IM_ERR_DATA: - printf("Image type not Suported.\n"); - break; - case IM_ERR_FORMAT: - printf("Invalid Format.\n"); - break; - case IM_ERR_COMPRESS: - printf("Invalid or unsupported compression.\n"); - break; - default: - printf("Unknown Error.\n"); - } -} - -imImage* LoadImage(const char* file_name) -{ - int error; - imFile* ifile = imFileOpen(file_name, &error); - if (!ifile) - { - PrintError(error); - return 0; - } - - imImage* image = imFileLoadImage(ifile, 0, &error); // load the first image in the file. - if (!image) - PrintError(error); - - imFileClose(ifile); - - return image; -} - -void SaveImage(imImage* image, const char* file_name, const char* format) -{ - int error; - imFile* ifile = imFileNew(file_name, format, &error); - if (!ifile) - { - PrintError(error); - return; - } - - error = imFileSaveImage(ifile, image); - if (error != IM_ERR_NONE) - PrintError(error); - - imFileClose(ifile); -} - -int main(int argc, char* argv[]) -{ - if (argc < 4) - { - printf("Invalid number of arguments.\n"); - return 0; - } - - // Loads the image from file - imImage* image = LoadImage(argv[1]); - if (!image) - return 0; - - // Creates a new image similar of the original but with complex data type. - // FFTW does not requires that the image size is a power of 2. - imImage* fft_image = imImageCreate(image->width, image->height, image->color_space, IM_CFLOAT); - if (!image) - return 0; - - // Forward FFT - imProcessFFTW(image, fft_image); - - // The user processing - FreqDomainProc(fft_image); - - // The inverse is still a complex image - imImage* ifft_image = imImageClone(fft_image); - if (!image) - return 0; - - // Inverse FFT - imProcessIFFTW(fft_image, ifft_image); - - // Converts the complex image to the same type of the original image - // so we can reuse its buffer - // (usually will be a bitmap image so we can also view the result) - if (image->data_type != IM_CFLOAT) - { - // This function will scan for min and max values before converting the data type - // There wiil be no gamma conversion, use abssolute values, and only the real part will be considered. - imConvertDataType(ifft_image, image, IM_CPX_REAL, IM_GAMMA_LINEAR, 1, IM_CAST_MINMAX); - } - - SaveImage(image, argv[2], argv[3]); - - imImageDestroy(image); - imImageDestroy(fft_image); - imImageDestroy(ifft_image); - - return 1; -} diff --git a/html/download/samples_imlua5.tar.gz b/html/download/samples_imlua5.tar.gz Binary files differindex 33a199b..849e964 100644 --- a/html/download/samples_imlua5.tar.gz +++ b/html/download/samples_imlua5.tar.gz diff --git a/html/download/samples_imlua5.zip b/html/download/samples_imlua5.zip Binary files differindex 5163b90..f47c067 100644 --- a/html/download/samples_imlua5.zip +++ b/html/download/samples_imlua5.zip |