image processing

This is a discussion on image processing within the C Programming forums, part of the General Programming Boards category; Yes, that looks about right. -- Mats...

  1. #46
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, that looks about right.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  2. #47
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by mike_g View Post
    You seem to have mixed up blue and green. Colour elements tend to go RGB.
    This is far from guaranteed. Traditionally, Windows draws in "BGR" at the hardware level - it may well represent the image as RGB in user-mode, but once it gets to the driver it will be BGR. [Don't ask me where this comes from - but the hardware I worked on had a bit to say "RGB" or "BGR" when you configure the chip - and it looks "real funny" if you get it wrong].

    There's obviously no importance to the order of the colours if we are inverting them - all colours are treated equally. If we were to do things like colour adjustment, we obviously need to understand which colour is which.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #48
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    Quote Originally Posted by matsp View Post
    Yes, that looks about right.

    --
    Mats
    actually shouldnt it be data(ep100_lib_get_data)

    ?

  4. #49
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by taurus View Post
    actually shouldnt it be data(ep100_lib_get_data)

    ?
    No, ep100_lib_get_data() is a function, and data is, in what you've posted earlier, an array.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #50
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    quick question, i cant really understand the difference between these 2, they sound the same:
    // This routine will put the image pixel data into the supplied matrix
    // from top left to bottom right. You must ensure that enough space is
    // available.
    void ep100_lib_get_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);

    // This routine will set the image pixel data from the supplied matrix
    // from top left to bottom right. You must ensure that enough space is
    // available.
    void ep100_lib_set_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);

  6. #51
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by taurus View Post
    quick question, i cant really understand the difference between these 2, they sound the same:
    // This routine will put the image pixel data into the supplied matrix
    // from top left to bottom right. You must ensure that enough space is
    // available.
    void ep100_lib_get_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);

    // This routine will set the image pixel data from the supplied matrix
    // from top left to bottom right. You must ensure that enough space is
    // available.
    void ep100_lib_set_data(int data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]);
    Red words should make it clear which does what - no, they don't do the same thing, just like getchar() and putchar() don't do the same thing.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #52
    Registered User
    Join Date
    Aug 2007
    Posts
    270

    Post

    ok iv done some work, hopefully iv understood it, so could someone have a look through this pseudocode and advice further(it has left out somethings):

    Code:
    // Invert the image (1 = first argument after a.out)
    IF argv[1] = -i THEN
    INTEGER data[EP100_LIB_MAX_X][EP100_LIB_MAX_Y]		
    ep100_lib_get_data(data)
    ep100_lib_print_data(data)
    
    FUNCTION invert_image(data)
    
    ep100_lib_set_data(data) // Display original image
    
    SLEEP  5 // Pauses program for 5 seconds
    
    	ep100_lib_display_image(); // Display inverted image
    Code:
    ALGORITHM invert_image
    
    INTEGER FUNCTION invert_image(INTEGER data[EP100_LIB_MAX_X] [EP100_LIB_MAX_Y])
    FOR X  1 to EP100_LIB_MAX_X DO
    	FOR Y  1 to EP100_LIB_MAX_Y DO
    		INTEGER data[EP100_LIB_MAX_X] [EP100_LIB_MAX_Y]
    		red  ((data[X][Y]>>16)&0xff)
    		blue  ((data[X][Y]>>8)&0xff)
    		green  ((data[X][Y])&0xff)
    		
    		data.red  255 – data.red
    		data.blue  255 - data.blue
    		data.green  255 - data.green
    		
    		RETURN 
    	ENDFOR
    ENDFOR
    
    END ALGORITHM

    THANKS

  8. #53
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Like I said in a different post, you probably want to use the image's actual dimensions, as if you have a 100 x 100 pixel image, and your Max X/Y values are 1000, you'll process 990000 pixels out of a million worht of "emptyness", which is a bit of a waste, don't you think.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #54
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    that ep100_lib_max x etc is defined as 1024
    in the assignment it didnt say we get the dimensions from user, we just have to use CLA where a.out -i image.jpeg
    -1 = invert

    but otherwise does it look alright?

  10. #55
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    > SLEEP  5 // Pauses program for 5 seconds
    I don't think you should be using SLEEP, I think I read it's not portable/ resource heavy ?

  11. #56
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    // This function returns the width in pixels of the loaded image.
    int ep100_lib_get_image_width();
    
    // This function returns the height in pixels of the loaded image.
    int ep100_lib_get_image_height();
    was posted by you in another thread. You don't think those functions would do exactly what you need to avoid making 99% of the work unnecessarily?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #57
    Registered User
    Join Date
    Aug 2007
    Posts
    270
    ohhhh ya k, ill change that, thanks for reminding me!

    now its just how to scroll i have to work on

  13. #58
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ICool View Post
    > SLEEP  5 // Pauses program for 5 seconds
    I don't think you should be using SLEEP, I think I read it's not portable/ resource heavy ?
    Not to mention that it's completely meaningless. Why would you want to make it run slower than it can? [it won't be INSTANT anyways - although it shouldn't take more than fractin of a second.

    If you want to PAUSE soemthing, then you ask the user to press enter or some such - that way, the pause is the right length for the user to see whatever is happening. Waiting X seconds just gets annoying.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #59
    Registered User
    Join Date
    Sep 2007
    Posts
    104
    I as thinking about scrolling :
    Here for this example
    Code:
    1 2 3 4 5 
    1 2 3 4 5
    1 2 3 4 5
    To get it scrolled to this :
    Code:
    4 5 1 2 3
    4 5 1 2 3
    4 5 1 2 3
    This being a horizontal scroll I assume I need to work out where there is a "split" line , dump the contents either side of the split line into 2 arrays , and then rejoin the arrays , swapping their order . Would this be a good way to do it ?

  15. #60
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You could do that. Or you could just copy everything into a new data-set and copy it with "offset". The latter may be easier.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 4 of 6 FirstFirst 123456 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 05:17 AM
  2. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 01:10 PM
  3. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  4. Memory Allocation in Intell Image processing liberary
    By nisar in forum Windows Programming
    Replies: 0
    Last Post: 01-12-2003, 07:29 AM
  5. Image rotation using intel image processing
    By sunis in forum Windows Programming
    Replies: 1
    Last Post: 11-18-2002, 02:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21