Help contrast stretch

Hi all,
How to apply a simple contrast stretch algorithm on grayscale Image?
Image inImage = new ImageIcon(f.getAbsolutePath(), f.getName()).getImage();
          int maxDim = 110;
                double scale = (double) maxDim / (double) inImage.getHeight(null);
                if (inImage.getWidth(null) > inImage.getHeight(null))
                    scale = (double) maxDim / (double) inImage.getWidth(null);
                int scaledW = (int) (scale * inImage.getWidth(null));
          int scaledH = (int) (scale * inImage.getHeight(null));
                Image img = inImage.getScaledInstance(scaledW , scaledH, Image.SCALE_SMOOTH);
                //Grayscale images
                Image filtered = Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(img.getSource(), new GrayscaleImageFilter()));
                //Converto tipo Image in PlanarImage
                ParameterBlock pd = new ParameterBlock();
                pd.add(img);
                PlanarImage img_original = JAI.create("awtImage", pd);
                ParameterBlock pb = new ParameterBlock();
                pb.add(filtered);
                PlanarImage img_gray = JAI.create("awtImage", pb);
                ParameterBlock pbMaxMin = new ParameterBlock();
                pbMaxMin.addSource(img_gray);
                RenderedOp extremaOp = JAI.create("extrema", pbMaxMin);
                // Get the extrema of all bands !
                double[] allMins = (double[])extremaOp.getProperty("minimum");
                double[] allMaxs = (double[])extremaOp.getProperty("maximum");
                for(int b=0;b<allMins.length;b++)
                System.out.println("Band "+b+" values are between "+allMins[b]+" and "+allMaxs);
//BufferedImage myBufImg = img_gray.getAsBufferedImage();
// CONTRAST STRETCH ?????
DisplayJAI original_image = null;
original_image = new DisplayJAI(img_original);
jToolBar1.add(original_image);
jToolBar1.revalidate();
DisplayJAI gray_image = null;
gray_image = new DisplayJAI(img_gray);
jToolBar3.add(gray_image);
jToolBar3.revalidate();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Thank you very much! That's exactly what I was looking for.
Best,

Similar Messages

  • Contrast Stretching

    Hey everyone,
    Does anyone know anything about contrast stretching. I can't seem to find much on the net for it.

    I can't seem to find much on the net for it.No not much on the net! Only two million hits!
    http://www.google.co.uk/search?hl=en&q=contrast+stretching&btnG=Google+Search&meta=

  • Contrast stretch -- is this possible in PhotoShop?

    I have an image (A.jpg).
    The image shows some horizontal stripes (in darker shades) when stretched.
    I want to fix the horizontal stripes without chaning other pixel values. A simple copy/paste of neighboring pixels would be good enough.
    Here's my problem. If I stretch the image, I can see the stripes and edit pixels, but I loose all the original pixel values. Without stretching, I cannot see the stripes.
    Is it possible to edit original pixel values with a 'visually' stretched display?
    I will appreciate any help, suggestion or comments.
    Thanks!

    Thank you very much! That's exactly what I was looking for.
    Best,

  • Stretching desktop across two monitors with FX5600

    Hi
    Can anyone please help me stretch my desktop across two monitors? I have just purchased an MSI FX 5600 VTD256 and am using it on a P4P800 ASUS Motherboard and Windows XP Machine. I can't get the desktop image to stretch over my two monitors. Instead it duplicates on each one. This is causing further problems within the CAD package I am using, as the dialog box positions are not being remembered.
    Any help much appreciated.
    Cheers,
    Link.

    what driver version are you using ?
    because they updated nview in the latest version to simplify it
    anyway in the old ones (Nview 2.0) you dat to check the "Treat different outputs on the ... as separate videocards" or something lyke that in Display->properties->advanced->nvidia ...
    in the new ones (Nview 3) is pretty much the same ... just look for it

  • Stretching images on Keynote for iPad

    Hello Helpful Community,
    Stretching shapes on Keynote for iPad works in the usual way, but stretching doesn't seem to work for images. It's as if the aspect ratio is fixed. Any suggestions?
    Thanks!
    jacob111

    wrong discussion, ask this in the:     iOS discussion

  • Contrast Strech on Planar Image

    Hi all,
    How to apply a simple contrast stretch algorithm on 8bit RGB PlanarImage.
    Please note that, stretch is interactive. The user will specify min and max value of histogram , by moving the slider.
    Edited by: java_explorer on Jul 15, 2008 9:09 PM

    Hi,
    For Histogramm equalization look at the
    HistogramDescriptor class of JAI.
    Olek

  • Evening Out The Brightness and Color of a Set of Images

    So I have a set of images, usually between 500-700, all taken in a 20min period or so. Natural light through a window. It's shot handheld with my Canon rebel with a 18-55mm lens. Due to the slight change in light over the time period, the fact I'm zooming in and out, and moving around the subject, I get a lot of value and color variation. See the images below...
    My current process is to manually color correct each image so they match in terms of brightness and color. This gets very tedious of course. Could someone suggest a faster, preferably completely automated way to even out the brightness and colors of a set of images like these in lightroom so they all look pretty similar to each other?
    Thanks for any help!
    - Neil

    Hi léonie,
    >> One problem - it is not only the different color of the light because of the setting sun.
    >> Your Harry and Harold are receiving the sun light from different directions. Harold is
    >> facing away from the sun and the light in the shadows is much bluer. I doubt you will
    >> be able to "Lift&Stamp" the adjustment between these two groups of images without
    >> fine tuning it. The "shady" Harold will need additional color correction to turn the bluish
    >> shadows into sunlight, because the shadow regions need contrast stretching and
    >> more vibrancy as well.
    Yup, that's one reason I think I need a color correction after the fact method to handle this situation, obviously taking a shot that's mostly in shadow will look different than one where the character is almost all in complete sunlight.
    I guess I'm really having three issues here, first is the blue tint that gets introduced when I zoom in, and then second is the natural lightening and darkening that occurs as I take photos of the subject from different angles, and third is the fact since its sunlight the light does change somewhat over the 20minute period.
    Hopefully the first issue can be solved by turning off automatic white balance, and I'm still hoping there may be some automated method for evening out the value difference introduced by the 2nd and third issue. Although even if I can just solve the first issue that would save me a ton of time.
    Thanks for the info so far.
    - Neil

  • Is there any Airport Extreme card diagnostic software?

    Is there any diagnostic software, or open firmware commands I can use to track down and diagnose problems with my Airport Extreme card?
    Are there any hardware tests that can be performed on it?
    At a higher level, is there anything I can do to diagnose problems with connections to an Access Point? (I don't have an Airport base station, unfortunately, I recall there being lots of tools for this).
    I've looked in /var/log/system.log, but it's not too helpful - contrast this with the vast amount of diagnostics you get on (say) a Linux system... can you enable some "debug mode"?
    Can I monitor received / transmitted signal strength from the card?
    iBook G4 ~900MHz   Mac OS X (10.3.4)   Airport Extreme card, D-Link DSL-G604T AP

    Don, thanks for the reply.
    In this case, it's not a problem with my ISP, as I can access Internet sites from other systems connected to my wireless/LAN router that are connected on the LAN.
    It's not a problem with the wireless side of the wireless router, as I can connect from other wireless systems.
    I do have problems where resetting the router is the only cure, but this isn't one of them!
    The symptoms I was having on the Mac side were:
    a) I saw only grey bars in the signal strength status icon - i.e. useless signal.
    b) I clicked it, and did 'Turn AirPort off', then 'on' again - this usually 'kicks' most problems.
    c) this didn't result in a good connection - Internet Connect showed that the AirPort Extreme card was connecting to the correct network and base station ID, then disconnecting after a few seconds.
    (Similar to that discussed at
    http://discussions.apple.com/thread.jspa?threadID=380635 )
    It looked like my AirPort Extreme had developed a fault (gone 'deaf')... I opened the iBook, reseated the card, clicked the antenna lead back in, but this had no effect.
    At this stage, I was ready to take the iBook into the Regent St. Genius Bar, but out of desperation, re-entered the connection details / WPA personal password in System Preferences.... and it all started working!
    So I don't currently have a problem, but would like to know if there is any hardware diagnostic for the card, so I can rule out hardware fault in future.
    Regards,
    Matt
    iBook G4 ~900MHz Mac OS X (10.3.4)

  • Noise Reduction Programs as External Editor

    Can anyone tell me if I can set up a noise reduction program (Noiseware, Noise Ninja, Neat Image, etc) as an external editor to LR and use the "round trip" feature used with PS/PSE? I don't currently have either PS or PSE, since LR has been able to handle my editing needs with the exception of noise reduction. Hence my research into free-standing programs.
    Thanks in advance.
    Adam

    From the Noise Ninja web site:
    http://www.picturecode.com/wiki/index.php/Main_Page
    "It is usually best to apply noise reduction as early as is practical in the workflow. Post-processing adjustments like sharpening, contrast stretching, and color balancing can alter pixel values and noise levels in unpredictable ways. Depending on the amount of adjustment, this can make it more difficult for Noise Ninja to estimate noise levels. Sharpening, for instance, is a nonlinear operation that can significantly distort the distribution of noise values.
    If your workflow requires that you use Noise Ninja after some other operations, then try to create noise profiles using calibration images that have been put through the same operations.
    Running Noise Ninja early in the workflow is a good rule of thumb, but Noise Ninja can be applied at any time. Sometimes it may not be possible or practical to run Noise Ninja at an earlier point in the workflow. For example, most users are not using a RAW processor with plug-in that allows Noise Ninja to be run before other adjustments in the RAW processor."

  • Noise Ninja Workflow

    I tried to initiate this topic of discussion in the NN online forum, but participation seems light there.
    The NN FAQ states the following: "It is usually best to apply noise reduction as early as is practical in the workflow. Post-processing adjustments like sharpening, contrast stretching, and color balancing can alter pixel values and noise levels in unpredictable ways. Depending on the amount of adjustment, this can make it more difficult for Noise Ninja to estimate noise levels. Sharpening, for instance, is a nonlinear operation that can significantly distort the distribution of noise values.
    If your workflow requires that you use Noise Ninja after some other operations, then try to create noise profiles using calibration images that have been put through the same operations.
    Running Noise Ninja early in the workflow is a good rule of thumb, but Noise Ninja can be applied at any time. Sometimes it may not be possible or practical to run Noise Ninja at an earlier point in the workflow. For example, most users are not using a RAW processor with plug-in support so they run Noise Ninja after the RAW processing step."
    Although it seemed less than obvious in this statement that RAW processing must be completed before editing with the NN plugin, but this would appear to be the case, since the plugin is not using RAW file, and the file returned is no longer subject to the normal edit controls used for RAW images?
    But when now going back over many existing projects and images to enhance via NN, the question is really to the difference between applying NN to the existing Versions, versus trying to back up to a point prior to adjustments having been applied that are not dependent upon RAW processing?
    What are the Pros and Cons of what was stated above: "using a RAW processor with plug-in support so they run Noise Ninja after the RAW processing step" insofar as processing new images?
    Ernie

    Ernie Stamper wrote:
    The NN FAQ states the following: "It is usually best to apply noise reduction as early as is practical in the workflow...Sometimes it may not be possible or practical to run Noise Ninja at an earlier point in the workflow. For example, most users are not using a RAW processor with plug-in support so they run Noise Ninja after the RAW processing step."
    Well, since NN does not have its own raw converter, it has to work with tif, jpeg files. Which means that raw file was converted somewhere. My guess is that many are converted to tif or jpeg in the camera; hence, the profiles are available for various camera models and ISO settings.
    Since each raw converter translate sensor data differently, how it handles noise is also subject to different algorithms.
    Although it seemed less than obvious in this statement that RAW processing must be completed before editing with the NN plugin, but this would appear to be the case, since the plugin is not using RAW file, and the file returned is no longer subject to the normal edit controls used for RAW images?
    The stand alone NN app does not read raw files. Just more options than the plug in. Once tif file is returned to Aperture environment, all the adjustments are available, except ones that has to do with raw conversion.
    But when now going back over many existing projects and images to enhance via NN, the question is really to the difference between applying NN to the existing Versions, versus trying to back up to a point prior to adjustments having been applied that are not dependent upon RAW processing?
    Why not just create new version from master, adjust white balance, then use NN. The plug-in tif file is also non-destructive and can apply all the Aperture controls.
    What are the Pros and Cons of what was stated above: "using a RAW processor with plug-in support so they run Noise Ninja after the RAW processing step" insofar as processing new images?
    In most simplistic terms:
    Pro: less noise in high iso images
    Con: large tif files, leads to less details in the image
    There is a tradeoff between retaining all the sharpness that you'd like versus getting rid of noise that degrade the image quality - it is a personal choice.

  • How to get super sharp pictures without stand with canon 60D?

    When you mention a stand, are you referring to a tripod?

    There are many things you can do... good techniques you can learn. These work with any camera, not just the 60D... 1. Use a tripod. I mean, why not, if it's possible? Alternatively, use a monopod. Or steady the camera and lens on a rock or fence or against a tree. When possible, use something to help steady your shot. Of course, it's not always possible! NOTE: An exception is if in a moving vehicle - an airplane or a car for example - it's usually just the opposite. Even if the vehicle is stopped, but the engine is running, you don't want the camera to touch any of the hard surfaces because vibrations will cause blurring. In effect, use your body to insulate and isolate the camera from the vehicle vibrations. 2. Use a faster shutter speed. Slow shutter speeds are just asking for camera shake blur. This may mean bumping up your ISO (use 400 instead of 100, for example). Or, you might need to use a larger aperture. Or you might need to do a little of both. 3. Longer focal length lenses are harder to hold steady than shorter. So a rule of thumb is that your shutter speed should be the reciprocal of your lens focal length. If you are using a 50mm lens, you should try not to use slower than 1/50 shutter speed. If you are using a 200mm lens, try not to go below 1/200. 400mm lens, keep to faster than 1/400. Actually, the 60D is a crop sensor camera, which magnifies susceptibility to camera shake at the same time it magnifies the image in the camera, so by rights you should use slightly faster shutter speeds. That 50mm lens on the crop camera behaves like an 80mm lens on a full frame camera and the rule of thumb regarding shutter speeds is actually based upon full frame. So you might want to keep to 1/80 or faster with that 50mm (but to be honest I manage to use the simple reciprocal with my crop cameras... and even slower... but I've had lots and lots of practice and use a number of stabilized lenses, as well).   4. Use stabilized lenses. Canon's IS (Sigma's OS and Tamron's VC) allow you to use somewhat slower shutter speeds and still get a steady shot. NOTE: if using a tripod, with some stabilizzed lenses you must manually turn off IS, otherwise in the absence of any movement the IS will get into sort of a feedback loop where it's actually inducing movement, instead of counteracting it.   5. Speaking of aperture, most lenses aren't at their sharpest wide open. Stop down a little. If yours is an f4 lens, try f5.6. My 50mm f1.4 lens is not at it's best at f1.4, but is quite good at f2. 6. However, at the same time try to avoid using too small apertures. Really small apertures such as f22 cause an effect known as "diffraction". This robs fine detail from images, giving a less sharp appearance. On your 60D, try to use no smaller than f11... maybe f16 at the smallest. Your images will thank you. 7. For handheld shots, learn good holding techniques until they are second nature. Cradle the lens in your left hand, with your right hand gripping the camera. Stand at a slight angle to your subject, one foot slightly ahead of the other and your feet about shoulder-width apart. Stand flat-footed. Keep your elbows tucked in fairly close to your torso. 8. Press the shutter release gently... don't stab at it or tap it. This is much like shooting a gun, where you gently pull the trigger rather than jerking it, to maintain accuracy. 9. If using slow shutter speeds (say 1/30 and below), first use a tripod... But also use a timer delay or remote release so that you aren't touching the camera at the time of exposure. Also use mirror lockup or Live View (which also does mirror lockup). This is so that the "bump" from the mirror and vibrations it causes don't blur the image. Mirror lockup is important on shutter speeds between about 2 seconds and 1/30. Faster and longer shutter speeds don't show problems from mirror "bump" vibrations. 10. Set your camera to a high frame rate and fire off a short burst of shots. The first image might be blurred, but others in the series are likely to be sharp as you hold the shutter button down for the duration of the burst. There are other tricks, but these are the major ones. Also don't mistake other causes of blur for camera shake. Even if you are doing everything right when using a slow shutter speeed, if the subject moves that can create blur in the image. It could be the wind blowing flowers or tree branches, even. Usually it's camera shake if the entire image is showing movement blur. Localized blur is usually due to subject movement. But it also can be a missed focus issue. Learn to tell them apart. I'd also recommend keeping your camera sensor clean, a dirty sensor can make an image look soft (shouldn't be a big deal with a 60D, which has a self-cleaning sensor that's pretty effective). And remove any filters from your lenses... they can and do cause image sharpness issues. In certain atmospheric effects, a polarizer or sky/haze filter might enhance sharpness... but in many situations any filter will costs some resolution. It might be very little under ideal conditions if the filter is very high quality, multi-coated. Or it might be a lot of loss, if the filter is lower quality and single coated or uncoated. Use a lens hood... it can prevent oblique light from striking your lens, which helps contrast and reduces flare. Might help with focus speed and accuracy, too.    

  • I have filmed my subject at 2000 fps on a JVC GY-HM750E, what settings do i need to use in FCP Studio 3 to get full advantage of this footage?

    So far just the usual ball dropped in water as a test...

    PhBalanced wrote:
    Hi David,
    What I'm trying to achieve is super slow motion footage for a webfilm I'm doing... Showing lots of detail very slowly...
    Any ideas how I can do this?
    steve
    You are confusing shutter speed with frames per second, an all too common issue around here. Super slow motion requires fast shutter speeds to prevent motion blur on each exposure but it also requires more than 60 discrete images per second. In ye olden days of shooting film, slow motion was achieved by overcranking the camera. We'd shoot 7s frame per second, 3 times the normal rate of 24fps. This required 8 times as much f-stop because we were shooting at 1/3 the shutter speed, too, 1/120th second instead of 1/40th or so. When the film was projected at normal speed, 24fps, each second of real time was stretched to three seconds of film time.
    You can use Motion's optical flow, which uses predictive pixel mapping, to help you stretch out some media but the results are not the same as using the correct acquisition techniques. You can also buy third party effects like Twixtor.
         bogiesan
    Message was edited by: David Bogie Chq-1

  • Small Changes to Save Big Bucks

    These five tried-and-true money saving tricks will help you stretch your dollar and get the best bang for your buck.

    Might be a caching issue. Have you tried different browsers or clearing your browser cache?
    Are you hosting on Business Catalyst or a third party hosting service?

  • Mac mini and LG monitor: screen is stretched and resolution is awful. Can someone help me fix this please?

    I have a Mac mini (bought in 2013) and the LG 20EN33 screen. I tried filing with the monitor's settings as well as the ones in display but the screen is stretched and the font is quite big. I saw a thread about Switch Res X so downloaded the app, but have no idea where to start to use it to correct issue. can someone help me please?

    You monitor is
    1600 x 900
    and only have VGA input
    http://www.lg.com/africa_en/monitors/lg-20EN33/technical-specifications
    With Switch-X you want to change the resolution to match your monitor's resolution.
    You have an old monitor and it may be best to get a new one that support the the now standard 1080p (1920X1080) resolution.
    I have not ideal how Switch-X works since I use the free version of Display Menu fro the Mac App Store

  • Brightness/Contrast edit tool messes up my clips.HELP!

    When I try to apply brightness/contrast to my iMovie 6.0.3 video clips (because so many of them end up much darker on iMovie than on my camcorder), it helps with the brightness, but after the rendering is done, my clip is messed up in 2 ways: 1) the sound is mainly gone, except for a few jerky sounds here and there; 2) visually, the clip is now jerky--like it's both in slow motion and being fast forwarded at the same time, if that makes sense. I've tried again and again, looked for advice all over the internet, to no avail, and wonder if it's just a glitch in my software and if so, what to do about it? (I did download an update on 6.0 from the Apple site, but it didn't help). Thanks!!

    Hi Z
    As Catspaw writes.
    The Brightness & Contrast tool in iM6 should work - a new account is a smart way to test
    where the problem originate.
    This tool in iMovie HD 6 - is crude and hard to use/get a good result with.
    In iMovie'08 - this is one of the few things that is a real improvment but the loss
    of so much other tools results in a useless situation (as Catspaw - I don't nearly use it)
    Solution: FinalCut Express 4
    • Superb tools to correct brigtness, contrast and colors
    • So much more
    Cons
    • COST - It's not free but price is reduced with 30% after introduction of iMovie'08
    • Some new learning. Mainly in starting up (setting up scratch discs & Capturing process)
    Some says steap learning curve - there is a step but mainly there are so much new
    tools so it's really to learn as You progress with Your movie.
    Yours Bengt W

Maybe you are looking for

  • How to maintain different account assignment group for a material

    One of our items in plant A was extended in B to use in an business scenario. Since the item was extended using the copy function every change made in A seems to affect our Item master in B . What governs this? Since the item is manufactured in A the

  • Comcast Technician just told us that the connection we have is way over capacity

    I signed up for a package wtih 25Mbps of Internet speed.   Over the past few weeks, I've been consistently losing connection, or getting speeds between 2-4 Mbps.    My next door neighbor has had the same problems.   We both called Tech Support - my c

  • Windows Install Help on custom built PC

    Yesterday I had posted some problems about not being able to get past the initial screen and entering the BIOS settings after building a PC.  I have successfully moved past that point and am now trying to install windows. I have read posts and done t

  • How to re-synch primary and standby database?

    Hello everyone, Working on 10g R2/windows server 2003, I have configured a physical standby database but, I have an issue, and don't know how to resolve it. We were making an update that made some DDL and DML on our application, and for security reas

  • "Access Denied. Contact your administrator"

    Hello, We are a small company using WindowsServer2008R2 Enterprise software for our file server. Users are using Microsoft Office 2010 on Windows 7 Professional. All users have similar permissions. When I open a file from file server on my computer,