Matlab: Deleting pixels from an image (desperate)

Discussion in 'Programmer's Corner' started by Fadel Megahed, Jun 27, 2007.

  1. Fadel Megahed

    Fadel Megahed Thread Starter Member

    Joined:
    Jun 22, 2007
    12
    0
    Hi,

    I am working on this big project and i would like if anyone could help me generate a code that would delete all pixels under 20 from an image.
    I am really stuck in the project and I am desperate for your help
    Thanks a lot everyone,
     
    #1
  2. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    7,810
    957
    I'm not clear about your requirements. Do you want to remove the pixels from the image, or do you want to change the value of the pixels to some other value? The first would probably destroy the image. The second, depending on the meaning of less than 20, would produce something that looks like a false color image. It would also help to know what format the image is in. We are not blessed with clairvoyance or astral projection; you're just going to have to tell us, there is no other way.
     
    #2
  3. Fadel Megahed

    Fadel Megahed Thread Starter Member

    Joined:
    Jun 22, 2007
    12
    0
    The image is a .jpg one
    The function of the program is to remove the background out of the picture so that when a histogram is developed, it has the focus zones only

    Thanks
     
    #3
  4. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    7,810
    957
    OK. Assuming you know the format of a .jpeg file a program might look like the following:
    Code:
    Open filename.jpeg for input
    Open Modified_filename.jpeg for output
    Read and process header
    Copy header to output
    while(.not. EndofFile)
    {
        pixel = getNextPixel() ;
        if(pixel < 20) pixel = 0 ;
        writePixel(pixel) ;
    }
    Close(filename.jpeg) ;
    Close(Modifed_filename.jpeg) ;
    
     
    #4
  5. Fadel Megahed

    Fadel Megahed Thread Starter Member

    Joined:
    Jun 22, 2007
    12
    0
    It worked :)
     
    #5
  6. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    7,810
    957
    That's terrific, and you didn't even need a tutorial on the pseudo-code language I made up on the spur of the moment. I'm quitting my day job and going into language design. I may have a bright future. On second thought since retirement is just around the corner I think I'll find a couch and take a nap. Yeah...a nap, that's the ticket!
     
    #6
Loading...