BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • changing brightness and contrast in an nsimage

    9 answers - 1852 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I've been going around in circles with this one
    What is a good way to change the brightness and contrast in an NSImage?
    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does one
    return the contrast to it's original value? you specify that
    0% of the pixels lie at the histogram extreme, you can't get the
    original values back. I know of the ImagApp example showing how to
    use CIImage, but using that would require a re-write of quite a bit
    of code I'd rather not go there.
    I start with images that have maximum contrast to begin with (I get
    digital data from a sensor, then create an NSImage by scaling the
    pixel values from 0 -255). So when I stretch the contrast, a bunch
    of pixels hit the rails those values are gone forever. Same thing
    if I compress the contrast quantization destroys the original
    information. How do people typically deal with this? Take iPhoto.
    If I change the contrast, I can move the slider back to low contrast,
    and all the data seems to be there do they just not allow any data
    to hit the 0-255 rail, or is a temporary copy being stored? If I
    keep increasing contrast, quitting, increasing contrast, quitting,
    etc, I CAN destroy the information, and have to revert to original
    therefore, I'd say that not allowing data to hit the rail is not the
    answer.
    Any discussion, up to and including sample code, would be greatly
    appreciated.
    Thanks,
    Eric
    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com
    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.1 | | 1155 bytes | |

    Dec 2, 2005, at 9:29 PM, Eric Smith wrote:

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does
    one return the contrast to it's original value? you specify
    that 0% of the pixels lie at the histogram extreme, you can't get
    the original values back. I know of the ImagApp example showing
    how to use CIImage, but using that would require a re-write of
    quite a bit of code I'd rather not go there.

    Too bad, because that's how to do it.
    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.2 | | 1707 bytes | |

    CIImage wasn't even around until 10.4 there must be a way to
    handle this from an NSImage. Anyone out there use brightness and
    contrast controls on an NSImage, or the bitmap data associated with
    the NSImage?

    Thanks,
    Eric

    Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:

    Dec 2, 2005, at 9:29 PM, Eric Smith wrote:
    >
    >I've been going around in circles with this one
    >>

    >What is a good way to change the brightness and contrast in an
    >NSImage?
    >>

    >I've been playing with the vImage library for changing contrast,
    >using the vImageEndsInContrastStretch. This works, but how does
    >one return the contrast to it's original value? you specify
    >that 0% of the pixels lie at the histogram extreme, you can't
    >get the original values back. I know of the ImagApp example
    >showing how to use CIImage, but using that would require a re-
    >write of quite a bit of code I'd rather not go there.
    >

    Too bad, because that's how to do it.

    -jcr
    >
    >
    >

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.
    >
    >
    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.3 | | 2675 bytes | |

    I would recommend using CoreImage for doing this. There are AppKit
    categories on CIImage that are the same as NSImage API. There is also
    NSCIImageRep, or rendering your CoreImage into an NSImage. Any or
    some combination of these should allow you to slip CIImage into your
    system without modifying the rest of your code.

    In my application the difference between using NSImage and CIImage
    boils down to about 10 lines of code. (After many gyrations - see
    previous thread on CIImage performance)
    -Kenny

    Dec 3, 2005, at 7:04 PM, Eric Smith wrote:

    CIImage wasn't even around until 10.4 there must be a way to
    handle this from an NSImage. Anyone out there use brightness and
    contrast controls on an NSImage, or the bitmap data associated with
    the NSImage?

    Thanks,
    Eric

    Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:
    >
    >>

    >Dec 2, 2005, at 9:29 PM, Eric Smith wrote:
    >>

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does
    one return the contrast to it's original value? you specify
    that 0% of the pixels lie at the histogram extreme, you can't
    get the original values back. I know of the ImagApp example
    showing how to use CIImage, but using that would require a re-
    write of quite a bit of code I'd rather not go there.
    >>

    >Too bad, because that's how to do it.
    >>

    >-jcr
    >>
    >>
    >>

    >John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    >Roaming Cocoa Engineer,
    >Available for your projects at great Expense and Inconvenience.
    >>
    >>
    >>

    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %
    40pobox.com

    This email sent to kenny_leung (AT) pobox (DOT) com

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.4 | | 2534 bytes | |

    I think the problem is it isn't clear what you are asking for

    Are you asking for pointers to general brightness and contrast
    algorithms?
    Are you asking how to get at the NSImage bitmap data to manipulate it
    yourself?
    are you asking if there are other Apple supplied frameworks that
    will perform brightness and contrast adjustments for you?

    Dave

    Dec 3, 2005, at 8:04 PM, Eric Smith wrote:

    CIImage wasn't even around until 10.4 there must be a way to
    handle this from an NSImage. Anyone out there use brightness and
    contrast controls on an NSImage, or the bitmap data associated with
    the NSImage?

    Thanks,
    Eric

    Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:
    >
    >>

    >Dec 2, 2005, at 9:29 PM, Eric Smith wrote:
    >>

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does
    one return the contrast to it's original value? you specify
    that 0% of the pixels lie at the histogram extreme, you can't
    get the original values back. I know of the ImagApp example
    showing how to use CIImage, but using that would require a re-
    write of quite a bit of code I'd rather not go there.
    >>

    >Too bad, because that's how to do it.
    >>

    >-jcr
    >>
    >>
    >>

    >John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    >Roaming Cocoa Engineer,
    >Available for your projects at great Expense and Inconvenience.
    >>
    >>
    >>

    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %
    40criticalpath.com

    This email sent to dave (AT) criticalpath (DOT) com

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.5 | | 4069 bytes | |

    K. I have NSImages that I've created by filling an NSBitmapRep's
    data buffer with information that I get from an image sensor. When I
    create the rep, I scale all the data from the sensor so that I get a
    grayscale image spanning 0-255 in each color channel so I start
    with maximum contrast.

    So, part one of the problem is, what's the most efficient way of
    changing the brightness and contrast of this image? vImage uses
    Altivec, and was my first choice for speed. vImage does have a
    function for *increasing* the contrast works just fine. Problem
    is, I start with maximum contrast, so any contrast stretching causes
    information near the edges of the histogram to be lost ie,
    everything from, say, 200 - 255 gets mapped to 255. Question: how
    do people typically deal with this problem? Keep an original bitmap
    around in case one wants to reduce the contrast (get back all the
    original information) ?

    Part two of the problem: vImage has no brightness control (unless
    it's called something else, and I just don't recognize it that's
    possible). Does it exist somewhere else? Question: does Apple
    provide a set of routines that operate on either and NSImage, or the
    bitmap rep, that will change the brightness and contrast for me?

    I'd also be interested in general brightness and contrast algorithms,
    if anyone has info they'd like to pass along.

    Thanks,
    Eric

    Dec 3, 2005, at 7:30 PM, Dave Camp wrote:

    I think the problem is it isn't clear what you are asking for

    Are you asking for pointers to general brightness and contrast
    algorithms?
    Are you asking how to get at the NSImage bitmap data to manipulate
    it yourself?
    are you asking if there are other Apple supplied frameworks that
    will perform brightness and contrast adjustments for you?

    Dave

    Dec 3, 2005, at 8:04 PM, Eric Smith wrote:
    >
    >CIImage wasn't even around until 10.4 there must be a way to
    >handle this from an NSImage. Anyone out there use brightness and
    >contrast controls on an NSImage, or the bitmap data associated
    >with the NSImage?
    >>

    >Thanks,
    >Eric
    >>

    >Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:
    >>


    Dec 2, 2005, at 9:29 PM, Eric Smith wrote:

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does
    one return the contrast to it's original value? you
    specify that 0% of the pixels lie at the histogram extreme,
    you can't get the original values back. I know of the ImagApp
    example showing how to use CIImage, but using that would require
    a re-write of quite a bit of code I'd rather not go there.

    Too bad, because that's how to do it.

    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.


    >>

    >
    >Do not post admin requests to the list. They will be ignored.
    >Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    >Help/Unsubscribe/Update your Subscription:
    >%
    >40criticalpath.com
    >>

    >This email sent to dave (AT) criticalpath (DOT) com
    >>

    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.6 | | 2887 bytes | |

    K I've gone to the CIImage.

    Next question: I can create a CIImage from NSBitmapImagRep, but all
    I can get from the CIImage is an NSImageRep this has no method for
    getting at the bitmap data. I'm using a CIImage, how do I get
    the bitmap data?

    Thanks again,
    Eric

    Dec 3, 2005, at 7:30 PM, Dave Camp wrote:

    I think the problem is it isn't clear what you are asking for

    Are you asking for pointers to general brightness and contrast
    algorithms?
    Are you asking how to get at the NSImage bitmap data to manipulate
    it yourself?
    are you asking if there are other Apple supplied frameworks that
    will perform brightness and contrast adjustments for you?

    Dave

    Dec 3, 2005, at 8:04 PM, Eric Smith wrote:
    >
    >CIImage wasn't even around until 10.4 there must be a way to
    >handle this from an NSImage. Anyone out there use brightness and
    >contrast controls on an NSImage, or the bitmap data associated
    >with the NSImage?
    >>

    >Thanks,
    >Eric
    >>

    >Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:
    >>


    Dec 2, 2005, at 9:29 PM, Eric Smith wrote:

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing contrast,
    using the vImageEndsInContrastStretch. This works, but how does
    one return the contrast to it's original value? you
    specify that 0% of the pixels lie at the histogram extreme,
    you can't get the original values back. I know of the ImagApp
    example showing how to use CIImage, but using that would require
    a re-write of quite a bit of code I'd rather not go there.

    Too bad, because that's how to do it.

    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.


    >>

    >
    >Do not post admin requests to the list. They will be ignored.
    >Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    >Help/Unsubscribe/Update your Subscription:
    >%
    >40criticalpath.com
    >>

    >This email sent to dave (AT) criticalpath (DOT) com
    >>

    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.7 | | 732 bytes | |

    Dec 3, 2005, at 7:46 PM, Eric Smith wrote:

    Question: how do people typically deal with this problem? Keep
    an original bitmap around in case one wants to reduce the contrast
    (get back all the original information) ?

    That's how we did it before CoreImage, yes.
    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.8 | | 4016 bytes | |

    I've been wondering why this is so difficult, and I think that the
    answer is that all of this stuff is meant to be done in the display
    pipeline. If you want the bits back, you can probably use -[CIContext
    createCGImage:fromRect:]. If you are in the NSImage world, you can
    render into an NSImage and pull back the bits by creating an
    NSBitmapImageRep from the NSImage data:

    image = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
    [image lockFocus];
    [[NSGraphicsContext currentContext]
    ];
    [[self adjustedImage] drawInRect:NSMakeRect(0, 0, width, height)
    fromRect:NSMakeRect(0, 0, [self image_width], [self image_height])
    operation:NSCompositeCopy fraction:1.0];
    imageRep = [[NSBitmapImageRep alloc]
    (0, 0, width, height)];
    [image unlockFocus];
    data = [imageRep
    properties:nil];
    -Kenny

    Dec 3, 2005, at 9:39 PM, Eric Smith wrote:

    K I've gone to the CIImage.

    Next question: I can create a CIImage from NSBitmapImagRep, but
    all I can get from the CIImage is an NSImageRep this has no
    method for getting at the bitmap data. I'm using a CIImage,
    how do I get the bitmap data?

    Thanks again,
    Eric

    Dec 3, 2005, at 7:30 PM, Dave Camp wrote:
    >
    >I think the problem is it isn't clear what you are asking for
    >>

    >Are you asking for pointers to general brightness and contrast
    >algorithms?
    >Are you asking how to get at the NSImage bitmap data to manipulate
    >it yourself?
    >are you asking if there are other Apple supplied frameworks
    >that will perform brightness and contrast adjustments for you?
    >>

    >Dave
    >>

    >Dec 3, 2005, at 8:04 PM, Eric Smith wrote:
    >>

    CIImage wasn't even around until 10.4 there must be a way to
    handle this from an NSImage. Anyone out there use brightness and
    contrast controls on an NSImage, or the bitmap data associated
    with the NSImage?

    Thanks,
    Eric

    Dec 2, 2005, at 9:34 PM, John C. Randolph wrote:

    Dec 2, 2005, at 9:29 PM, Eric Smith wrote:

    I've been going around in circles with this one

    What is a good way to change the brightness and contrast in an
    NSImage?

    I've been playing with the vImage library for changing
    contrast, using the vImageEndsInContrastStretch. This works,
    but how does one return the contrast to it's original value?
    you specify that 0% of the pixels lie at the histogram
    extreme, you can't get the original values back. I know of the
    ImagApp example showing how to use CIImage, but using that
    would require a re-write of quite a bit of code I'd rather
    not go there.

    Too bad, because that's how to do it.

    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %
    40criticalpath.com

    This email sent to dave (AT) criticalpath (DOT) com

    >>

    >


    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %
    40pobox.com

    This email sent to kenny_leung (AT) pobox (DOT) com

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.9 | | 822 bytes | |

    Dec 3, 2005, at 10:02 PM, Kenny Leung wrote:

    I've been wondering why this is so difficult, and I think that the
    answer is that all of this stuff is meant to be done in the display
    pipeline.

    It's probably worth mentioning at this point that this can probably
    be done with no code at all, using a QC composition, and a QC Patch
    Controller.
    -jcr

    John C. Randolph <jcr (AT) mac (DOT) com(408) 914-0013
    Roaming Cocoa Engineer,
    Available for your projects at great Expense and Inconvenience.

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com

Re: changing brightness and contrast in an nsimage


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "BSD"

EMSDN.COM