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
    Messages:
    12
    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,
  2. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    Messages:
    6,018
    Location:
    Michigan, USA (GMT-5)
    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.
  3. Fadel Megahed

    Fadel Megahed Thread Starter Member

    Joined:
    Jun 22, 2007
    Messages:
    12
    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
  4. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    Messages:
    6,018
    Location:
    Michigan, USA (GMT-5)
    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) ;
    
  5. Fadel Megahed

    Fadel Megahed Thread Starter Member

    Joined:
    Jun 22, 2007
    Messages:
    12
  6. Papabravo

    Papabravo AAC Fanatic!

    Joined:
    Feb 24, 2006
    Messages:
    6,018
    Location:
    Michigan, USA (GMT-5)
    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!
Similar Threads
Forum Title Date
Programmer's Corner MATLAB radar signal processing Sep 16, 2014
Programmer's Corner Matlab parachute Aug 30, 2014
Programmer's Corner how to create diagonal movement in a matlab matrix Jul 24, 2014
Programmer's Corner MATLAB- Manipulate excel data into Matlab Jul 22, 2014
Programmer's Corner can anyone help with matlab program Jul 12, 2014

Share This Page