Image decomposition

Hi,

I’m having a small difficulty with several things related to using SDL as an image analysis library:
I’m currently working on a program that is suppose to analyze an image pixel by pixel, decompose it to RGB, and get the root mean square approximation, standard deviation, pearson and spearman’s coefficient of the RGB components within an image.

  1. I would like to dynamically allocate the size of the window depending on what image we load.

example: we load an image which is 200 x 400 pixels, the window will be 200 x 400. If the image is 300 x 400, the window will also be 300 x 400, etc. At the moment my window is static 640 x 480, but I’m having problems when loading images that exceed this value. I dont want the x, and y of the image to be an input parameter, since I will probably use this program to input thousands of pictures with completely random resolutions, and writing all the x and y resolution values by hand would be a pain.

  1. How do i hide the window that pops up, i want the program to calculate something in the background but have no window pop up.

  2. I would like the image (in this case its jpg) to be an input parameter for the start of the main program, i.e (int argc, char** argv), I give the directory of the image and its then used as an input to load an image.

How do I do the following 3 things, refference code would be helpful.

P.S - I’m aware of the existance of the SDL_image extension library and know how to use it.

Hello !

I am guessing you are using SDL 1.2 ?

  1. I would like to dynamically allocate the size of the window depending on what image we load.

example: we load an image which is 200 x 400 pixels, the window will be 200 x 400. If the image is 300 x 400, the window will also be 300 x 400, etc. At the moment my window is static 640 x 480, but I’m having problems when loading images that exceed this value. I dont want the x, and y of the image to be an input parameter, since I will probably use this program to input thousands of pictures with completely random resolutions, and writing all the x and y resolution values by hand would be a pain.

This sounds like you are trying to load the image into the SDL screen surface itself ?

http://sdl.beuc.net/sdl.wiki/Pixel_Access

Best is, upload a minimal compilable example of your code somewhere and
then post a link here.

  1. How do i hide the window that pops up, i want the program to calculate something in the background but have no window pop up.

SDL has something called a dummy video driver, which allows you to do
stuff like blitting, reading and setting pixels without any window poping up.

SDL_putenv(“SDL_VIDEODRIVER=dummy”);
in your code before using SDL_Init (…);

  1. I would like the image (in this case its jpg) to be an input parameter for the start of the main program, i.e (int argc, char** argv), I give the directory of the image and its then used as an input to load an image.

These are two different things. Either you give it (1) the path + filename of the image,
like /tmp/image.jpg or you give it (2) the path only like /tmp.

(1)
http://www.site.uottawa.ca/~lucia/courses/2131-05/labs/Lab3/CommandLineArguments.html

(2)
http://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Simple-Directory-Lister.html

CU

I don’t know about jpg but I know if it were a bmp that you could read the
file to find out the size of the image without loading it so you could load
it later after the setup.On Mon, May 28, 2012 at 11:23 AM, SmokeScreen <infested_one at wp.pl> wrote:

**
Hi,

I’m having a small difficulty with several things related to using SDL as
an image analysis library:
I’m currently working on a program that is suppose to analyze an image
pixel by pixel, decompose it to RGB, and get the root mean square
approximation, standard deviation, pearson and spearman’s coefficient of
the RGB components within an image.

  1. I would like to dynamically allocate the size of the window depending
    on what image we load.

example: we load an image which is 200 x 400 pixels, the window will be
200 x 400. If the image is 300 x 400, the window will also be 300 x 400,
etc. At the moment my window is static 640 x 480, but I’m having problems
when loading images that exceed this value. I dont want the x, and y of the
image to be an input parameter, since I will probably use this program to
input thousands of pictures with completely random resolutions, and writing
all the x and y resolution values by hand would be a pain.

  1. How do i hide the window that pops up, i want the program to calculate
    something in the background but have no window pop up.

  2. I would like the image (in this case its jpg) to be an input parameter
    for the start of the main program, i.e (int argc, char** argv), I give the
    directory of the image and its then used as an input to load an image.

How do I do the following 3 things, refference code would be helpful.

P.S - I’m aware of the existance of the SDL_image extension library and
know how to use it.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  1. You don’t need to resize the window since you don’t want it to popup.

  2. Maybe DevIL (http://openil.sourceforge.net/) or another similar
    library is more suitable for what you’re trying to do? This library will
    help you load different image formats and query them for their sizes,
    pixels etc. It doesn’t open any window, unlike SDL.

  3. Check if argc is 2 and, if it is, the image name will be at argv[ 1
    ]. If you’re passing a folder to the program to process its contents
    then you’ll have to play with opendir/readdir/closedir.

Cheers,

AndreOn 30/05/2012 23:53, R Manard wrote:

I don’t know about jpg but I know if it were a bmp that you could read
the file to find out the size of the image without loading it so you
could load it later after the setup.

On Mon, May 28, 2012 at 11:23 AM, SmokeScreen <infested_one at wp.pl <mailto:infested_one at wp.pl>> wrote:

Hi,

I'm having a small difficulty with several things related to using
SDL as an image analysis library:
I'm currently working on a program that is suppose to analyze an
image pixel by pixel, decompose it to RGB, and get the root mean
square approximation, standard deviation, pearson and spearman's
coefficient of the RGB components within an image.

1) I would like to dynamically allocate the size of the window
depending on what image we load.

example: we load an image which is 200 x 400 pixels, the window
will be 200 x 400. If the image is 300 x 400, the window will also
be 300 x 400, etc. At the moment my window is static 640 x 480,
but I'm having problems when loading images that exceed this
value. I dont want the x, and y of the image to be an input
parameter, since I will probably use this program to input
thousands of pictures with completely random resolutions, and
writing all the x and y resolution values by hand would be a pain.

2) How do i hide the window that pops up, i want the program to
calculate something in the background but have no window pop up.

3) I would like the image (in this case its jpg) to be an input
parameter for the start of the main program, i.e (int argc, char**
argv), I give the directory of the image and its then used as an
input to load an image.

How do I do the following 3 things, refference code would be helpful.

P.S - I'm aware of the existance of the SDL_image extension
library and know how to use it.

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org