Enlarged view of a part of an image

Hi folks I am preparing a project on "GPS vehile tracking system" and thats why I want to know a procedure to get an enlarged view of a part of an image.

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.*;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.event.*;
public class Magnifier
    BufferedImage image;
    SourcePanel sourcePanel;
    JLabel magLabel;
    double scale;
    public Magnifier(BufferedImage image)
        this.image = image;
        sourcePanel = new SourcePanel(image);
        ClipMover mover = new ClipMover(this, sourcePanel);
        sourcePanel.addMouseListener(mover);
        sourcePanel.addMouseMotionListener(mover);
        scale = 2.0;
    public void setImage()
        ImageIcon icon = new ImageIcon(getMagnifiedImage());
        magLabel.setIcon(icon);
    private BufferedImage getMagnifiedImage()
        Rectangle r = sourcePanel.clip;
        int x = r.x - sourcePanel.imageBounds.x;
        int y = r.y - sourcePanel.imageBounds.y;
        BufferedImage clipped = null;
        try
            clipped = image.getSubimage(x, y, r.width, r.height);
        catch(RasterFormatException rfe)
            System.out.println("r out of bounds: " + rfe.getMessage() + "\n" +
                               "\tx = " + x + "\t" +
                               "(x + w) = " + (x + r.width) + "\n" +
                               "\ty = " + y + "\t" +
                               "(y + h) = " + (y + r.height));
            return clipped;
        int w = (int)(scale * r.width);
        int h = (int)(scale * r.height);
        BufferedImage scaled = new BufferedImage(w, h, image.getType());
        Graphics2D g2 = scaled.createGraphics();
        g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
        g2.drawRenderedImage(clipped, at);
        g2.dispose();
        return scaled;
    private JPanel getCenter()
        magLabel = new JLabel();
        magLabel.setHorizontalAlignment(JLabel.CENTER);
        JPanel magPanel = new JPanel(new BorderLayout());
        magPanel.add(magLabel);
        JPanel panel = new JPanel(new GridLayout(1,0));
        panel.add(new JScrollPane(sourcePanel));
        panel.add(new JScrollPane(magPanel));
        return panel;
    private JPanel getSouth()
        final JLabel scaleLabel = new JLabel("scale = " + scale, JLabel.CENTER);
        int value = (int)(scale * 2);
        final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 8, value);
        slider.setSnapToTicks(true);
        slider.addChangeListener(new ChangeListener()
            public void stateChanged(ChangeEvent e)
                scale = slider.getValue()/2.0;
                scaleLabel.setText("scale = " + scale);
                setImage();
        JPanel panel = new JPanel(new GridLayout(1,0));
        panel.add(slider);
        panel.add(scaleLabel);
        return panel;
    public static void main(String[] args) throws IOException
        String path = "images/cougar.jpg";
        BufferedImage bi = ImageIO.read(Magnifier.class.getResource(path));
        Magnifier magnifier = new Magnifier(bi);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(magnifier.getCenter());
        f.getContentPane().add(magnifier.getSouth(), "South");
        f.setSize(500,400);
        f.setLocation(200,200);
        f.setVisible(true);
class SourcePanel extends JPanel
    BufferedImage image;
    Rectangle clip;
    Rectangle imageBounds;
    public SourcePanel(BufferedImage image)
        this.image = image;
        imageBounds = new Rectangle(image.getWidth(), image.getHeight());
    protected void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        int w = getWidth();
        int h = getHeight();
        int x = (w - imageBounds.width)/2;
        int y = (h - imageBounds.height)/2;
        g2.drawImage(image, x, y, this);
        g2.setPaint(Color.red);
        if(clip == null)
            clip = new Rectangle(x, y, 75, 125);
            imageBounds.x = x;
            imageBounds.y = y;
        g2.draw(clip);
    public void setClip(int x, int y)
        Point p = getLegalLocation(x, y);
        clip.setLocation(p.x, p.y);
        repaint();
    private Point getLegalLocation(int x, int y)
        if(x < imageBounds.x)
            x = imageBounds.x;
        if(x + clip.width > imageBounds.x + imageBounds.width)
            x = imageBounds.x + imageBounds.width - clip.width;
        if(y < imageBounds.y)
            y = imageBounds.y;
        if(y + clip.height > imageBounds.y + imageBounds.height)
            y = imageBounds.y + imageBounds.height - clip.height;
        return new Point(x, y);
    public Dimension getPreferredSize()
        return new Dimension(imageBounds.width, imageBounds.height);
class ClipMover extends MouseInputAdapter
    Magnifier magnifier;
    SourcePanel sourcePanel;
    Point offset;
    boolean dragging;
    public ClipMover(Magnifier m, SourcePanel sp)
        magnifier = m;
        sourcePanel = sp;
        offset = new Point();
        dragging = true;
    public void mousePressed(MouseEvent e)
        Point p = e.getPoint();
        if(sourcePanel.clip.contains(p))
            offset.x = p.x - sourcePanel.clip.x;
            offset.y = p.y - sourcePanel.clip.y;
            dragging = true;
    public void mouseReleased(MouseEvent e)
        dragging = false;
        magnifier.setImage();
    public void mouseDragged(MouseEvent e)
        if(dragging)
            int x = e.getX() - offset.x;
            int y = e.getY() - offset.y;
            sourcePanel.setClip(x, y);
}

Similar Messages

  • When I click on a picture to enlarge it on a web page ( any webpage),a new blank page opens with nothing.It only syas search bookmarks and history.What do I have to do to view an enlarged view says

    Using Firefox to search a web page.
    When I click on a picture to enlarge it on a web page ( any webpage),a new blank page opens with nothing.It only says" search bookmarks and history".
    What do I have to do to view an enlarged view ? What settings do i have to enable in firefox.
    Any help would be appreciated
    Colincolin30

    See:
    * [[Images or animations do not show]]
    * http://kb.mozillazine.org/Images_or_animations_do_not_load
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.<br />
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.<br />
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Adjusting color in part of an image in a photo.

    Hi, just bought Photoshop CC and am stuck.  I just received a photo of my uncle that was taken through the glass of the frame it was in.  The right side of his face is lighter than the rest of his face.  How do I adjust this color? You can also see some lightening of the lower right portion of his hat. Other issues have been corrected.  Portion of photo attached.  Thanks.

    Thank you so much.  I will give it a shot. Your help is greatly appreciated.  Will let you know how it works.
          From: musarticus <[email protected]>
    To: Gary Fletcher <[email protected]>
    Sent: Saturday, January 31, 2015 8:42 PM
    Subject:  Adjusting color in part of an image in a photo.
    Adjusting color in part of an image in a photo.
    created by musarticus in Photoshop for Beginners - View the full discussionTry this:  1) Duplicate your layer (Command/Control + J)2) Add a mask to the new duplicate layer3) Select the mask and either paint the left side black with your brush tool, or use the gradient tool for a black-to-white gradient4) Change the blend mode on the duplicate layer to "Multiply"5) If you want to go darker, duplicate the layer a second time and adjust the opacity as desired.6) In the image below I also masked out the background and added an orange photo filter to warm up the right side of the face. I cranked the filter to better see it, but you can reduce it to taste.7) There are other things you could try like painting with your brush in "Color" mode to fine-tune skin tones, or use the dodge and burn tools, etc.  https://forums.adobe.com/servlet/JiveServlet/downloadImage/2-7149917-723260/Multiply.png  If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7149917#7149917 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7149917#7149917 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Photoshop for Beginners by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • I am using adobe photoshop cs6. I am facing a problem. When i save any image as "save for web". After saving image it show cropped. An image show many parts of the image after saving the image. Please help me. Thanks in advance.

    I am using adobe photoshop cs6. I am facing a problem. When i save any image as "save for web". After saving image it show cropped. An image show many parts of the image after saving the image. Please help me. Thanks in advance.

    Just go back in photoshop and use the Slice Select tool, then just click and select the slice and hit delete - if you're not sure which one is the active slice just right click and find the one that has the Delete Slice option.
    It's possible you either added the slices by accident or if you received it from someone they just had the slices hidden. For the future, you can go to View > Show > Slices to display (or hide) slices.

  • I need to replace a color on my image with a specific color from another part of the image.  How?!

    I have spent over 2 hours trying to figure out how to replace a color on one part of my image with a specific color shown on another part of the image.  So far I have been able to go to "Replace Color" on my Adobe Photoshop version, but it seems that I can only change the hue and brightness of the color that it currently is.  I need to use a specific color so this does not help me.  Does anyone know how to complete the task I am referring to?
    Also, please keep in mind that I am using Adobe Photoshop 6.0, not a fancy cs version or anything.  So it's pretty old school...
    Any help/feedback is greatly appreciated!  Thank you.

    Hi brookehelene,
    You might consider making a selection the object and using a color fill layer set to the color blend mode instead of replace color.
    I used the same picture as kendallplant did and changed the color on the same flower by sampling the pink color from the flower to the right)
    (click on the screenshots below for larger views)
    1. Select>Color Range
       (i used color range because the dialog is somewhat similar to the replace color dialog, except one is making a selection instead of replacing a color)
       (there are many other ways to make the selection such as the magic wand, so if your more familar with the other selection tools you can use those instead to make your selection)
    2. Use the eyedroppers and fuzziness slider in the color range dialog to make the selection of the object.
       (in the screenshot below the white areas are selected and black areas are not)
       (your selection probably won't be perfect, but you can paint on the layer mask to refine the selection)
    3. After you press the okay in the color range dialog you'll see the selection (marching ants)
       At the bottom of the layers palette press the Create New Fill or Adjustment Layer icon
       to reveal a list and choose Solid Color.
       Then use the eyedropper to sample a color from your image and press ok.
       Change the Blend mode for the color fill layer to Color (top of the layers palette)
    4. As you can see a lot has been selected besides the flower.
        To refine the areas of color, paint on the layer mask with the paintbrush tool.
        Use white to add the color or black to subtract the color
        You can press the D key on the keyboard to get the default colors (black and white) in the toolbox
        and press the X key to switch between the two when painting on the layer mask.
    Even though the above takes longer you can easily change the color or modify the areas that you want to change the color on.
    To change the color you can double click on the color fill icon in the layers panel.
    You can also use other layer blend modes besides color such as hue, so you might try some of the others and see what they do.

  • InDesign only showing part of the image

    I'm doing a job for a client in InDesign CS5. I have not worked in CS5 before, so don't know if this is a bug or if I'm doing something wrong.
    It seems to happen randomly and I have checked the preferences and tried using different settings for the Display Performance. I've even tried viewing the job with Overprint Preview switched on.
    When placing images only a part of the image shows. When I output to PDF or Print the file then the entire image shows. This makes it very hard to do layouts, especially in cases where I need to crop an image.
    In InDesign it looks like this:
    When I output to PDF (this is a low res output, just to demonstrate my point) the entire image shows:
    In InDesign it looks like this:
    When I output to PDF:
    The machine I'm ding this job on is an iMac, 2.66GHz Intel Core 2 Duo with 4GB 800MHZ DDR2 SDRAM. It is running Mac OSX 10.6.4. And InDesign is on version 7.0.2.

    mafeiteng wrote:
    I'm doing a job for a client in InDesign CS5. I have not worked in CS5 before, so don't know if this is a bug or if I'm doing something wrong.
    It seems to happen randomly and I have checked the preferences and tried using different settings for the Display Performance. I've even tried viewing the job with Overprint Preview switched on.
    When placing images only a part of the image shows. When I output to PDF or Print the file then the entire image shows. This makes it very hard to do layouts, especially in cases where I need to crop an image.
    In InDesign it looks like this:
    When I output to PDF (this is a low res output, just to demonstrate my point) the entire image shows:
    In InDesign it looks like this:
    When I output to PDF:
    The machine I'm ding this job on is an iMac, 2.66GHz Intel Core 2 Duo with 4GB 800MHZ DDR2 SDRAM. It is running Mac OSX 10.6.4. And InDesign is on version 7.0.2.
    If I understand things correctly, you're placing client-supplied images into a new InDesign file that you're creating, so the only part of the workflow that you haven't created is the graphics. This logically leaves the container file innocent.
    The question becomes "what's up with either the hardware or the graphics?" If the problem persists with the same graphic files and a new container file on a different user account on the same computer, it's possible that hardware is the villain. If it doesn't persist on a different computer, it's likely the hardware. If it does persist on a different computer, in a new container file, it's likely something in the graphics files.
    It's not clear if the graphics card in your iMac is one of the models whose video RAM is "dedicated," that is, it doesn't share video RAM with the main RAM, or if it does share VRAM. If it shares RAM, it's possible that 4GB isn't sufficient to display all the open applications and their demands. If this is the cause, it's a hardware issue (insufficient RAM.)
    Because the graphics print and convert to PDF without the problem, it would seem that the graphics are innocent, but perhaps something in the processing of these outputs causes the problem to disappear. For example, perhaps there's some flattening involved. Perhaps there's a clipping path or channel mask of some kind involved that affects the InDesign display? (Just fishing.)
    Have you tried opening the graphics in their creating application and saving them to new names? Any difference in the behavior when those graphics are freshly-placed in InDesign, or when their links are updated?
    Have you tried placing PDFs of the graphics? If they appear properly, can you crop them to achieve your requirements and hope the problem goes away after the deadline passes<G>?
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • Is it possible to clone one part of an image into another in iphoto?

    Since it is not possible in Aperture to clone one part of an image into another photo is it possible in iphoto?

    No.  You will need to use an image editor that can handle layers.
    Some Image Editors that support  layers:
    Photoshop Elements 9 for Mac - $79
    GraphicConverter - $45
    Rainbow Painter - $30
    Imagerie - $38
    Acorn - $50 Pixelmator - $60 
    Seashore - Free
    Portraits and Prints - Free
    GIMP for Mac - Free
    Of those I believe you get the most bang for the buck with PSE 9.  The following are some of the advanced editing you can do with it:
    Click to view full size
    Click to view full size
    Additional possible candidates for editors can be found by searching for "edit" at MacUpdate.com.
    OT

  • Using applet to select a part of an image and then save it

    Hi ,
    I want to use applet to select a part of an image and then save that particular selected part to a server. can anyone provide me a code for this. I have found codes on the sun site which help in uploading an image but I am having trouble in trying to select a part of the image.

    Sorry to get back to you so late, but I was away from my computer this afternoon.
    I'm not sure just what you are after. I do see that you have positioned the tree on the labels. I went to the web site for the label company, and their instructions are not too helplful.
    http://www.pixentral.com/show.php?picture=15sBkl9OZE9xSkHoLMxgwjTFv2VCg1
    I changed the white portion of 1 label to black - - this can be any color. To do this use the magic wand tool, tolerance=10 worked for me, then go to Edit>fill selection.

  • How can I select only a small part of the image to clone or edit etc?

    I want to select part of the image to clone is, and just edit the selected part. I know i can do this on photoshop but how do i do it on Aperture?

    You use the "Retouche" brush in Aperture and set it to "clone".
    Option-Click on the location you want to clone from to select a source, and then brush over the location where you want to clone to. The cloned region will follow the shape of the brushed area. You do not lasso the shape to to copy and paste it like in Photoshop.
    For example: Duplicating a penguin: The sourcepoint has been set to the beak of the second penguin, and then I brushed along the path where I want to penguin clone to appear.
    If I brush the whole area eventually the penguin will be copied completely. You'll have to experiment a bit with the brush size and softnees to ensure that the cloned object will blend in.
    Regards
    Léonie

  • I have Office 2011 which includes Word.  Ever since downloading Mavericks, when I try to send a two-page word document, some recipients get only one page.  Also sometimes when I burn an image from iPhoto on to a disc, only part of the image appears.  Why?

    I have Office 2011 which includes Word.  Ever since downloading Mavericks, when I try to send a two-page Word document by email, some recipients get only one page.  Also when burning an image from iPhoto (usually no larger than 1mb) on to a disc, only part of it appears.  It appears to have been magnified so that only a part of the image appears.  Can anyone enlighten me as to what is happening?  And how to fix it??

    I have Office 2011 which includes Word.  Ever since downloading Mavericks, when I try to send a two-page Word document by email, some recipients get only one page.  Also when burning an image from iPhoto (usually no larger than 1mb) on to a disc, only part of it appears.  It appears to have been magnified so that only a part of the image appears.  Can anyone enlighten me as to what is happening?  And how to fix it??

  • My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need t

    My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need to. It appears as if I selected the entire layer on purpose (which I did not)
    The below items appeared when I opened Photoshop CS 5:
    “Photoshop has encountered a problem with the display driver and has temporarily disabled G & U enhancements. Check the video card malfunctions website for latest software. GPU enhancements can be enabled in the performance panel of preferences.”
    (I believe this started after the automatically updated Windows was applied. It was coincident with the before mentioned problem . . . but I don’t really know if it had anything to do with it. )

    For the Clone Stamp problem, check the Clone Source panel and Clipped is probably unchecked.
    If so, check Clipped and see if that makes a difference.
    (Window>Clone Source)
    As to the video card problem:
    Which version of windows are you using?
    What is the make and model of your graphics card?
    Do you know which update windows installed?

  • How do you cut out the part of an image in a photo?

    How do you cut out a part of an image on a photo that you have added to Pages. For example, if I have added a picture of a giraffe to Pages how would I cut out the giraffe from the image and get rid of the rest of the image

    You can use the instant alpha tool to make the background transparent.
    FYI: Pages is part of iWork, not iLife.

  • Is it possible to work only on a small part of the image in FCP ?

    Hello,
    I"m working on a DV film that I have made this winter, but on the original film, the image (video) is a lot darker on both top corners (I have some problems with my camera when I use it outside during the winter).
    Is there any way to work only on a part of the image with a filter, instead of working on the whole image. I would like to work on thoses 2 darker spot without touching the rest of the image.
    Thanks

    What you need to do is color correct just those two portions of the image. In a DaVinci and Final Touch this is called using "power windows." Now, you can do this one of two ways.
    1) Layer the same clip on the timeline 3 times. V1, V2 and V3. Same start and end time on all clips. Now, use the 4-point garbage matte on the clips on the upper layers to isolate those sections and then apply the 3-way color corrector to brighten the images.
    2) Colorista by Red Giant Software (www.redgiantsoftware.com) is a $200 color correction filter that allows you to layer color correction and isolate specific areas...using POWER WINDOWS in effect.
    Shane

  • How do you set up so that you can view the alternate text on an image when you hover over it like you do in IE?

    Using Mozilla at present the alternate text for an image does not pop up when you hover your mouse over the image. This is what occurs in Internet Explorer. In Mozilla Firefox you have to right click, choose Properties and then you can view the alternate text. Is there a way to set up the mouse hover? Or is there a keyboard shortcut to at least view the Properties information of an image on a webpage quicker?

    The Alt attribute isn't meant to show as a tooltip on hover.
    The Alt attribute is meant to show if the image isn't or can't be displayed.
    The title attribute is meant to show if you hover an image or link.
    *http://kb.mozillazine.org/Image_tooltips_do_not_work
    Some extensions can interfere and disable the tooltip.
    * [[Troubleshooting extensions and themes]]
    * http://www.w3.org/TR/html401/struct/global.html#title title
    * http://www.w3.org/TR/html401/struct/objects.html#alternate-text
    *Popup ALT Attribute: https://addons.mozilla.org/firefox/addon/1933

  • In iPhoto, how can I export images with the metadata - including the title and caption information - intact as part of the image?

    In iPhoto, how can I export images with the metadata — including the title and caption information — intact as part of the image?

    Check those boxes in the export dialogue - Exporting From iPhoto
    LN

Maybe you are looking for

  • Graphical artifacts with DX11 (and OGL4) on imac 27" late 2012 GTX 675 MX

    Hello, dear community! I have the imac 27" late 2012 with graphical card GTX 675 MX. In Mac OS X 10.8.5 all works perfect. Software, games (Bioshock Infinity), benchmarks (heaven 4.0). But in windows... I was installed Windows 8, then 7, then 8 again

  • In TOAD, Need to Enable DB Health check option

    Hi, I am using TOAD 10.1.1.8 DBA Suite. As my TOAD DBA Suite, DB Health check option should be there under Database -> Diagnose -> DB Health Check. But its not showing this option. Kindly guide me as How to enable DB Health check. Expecting your valu

  • DVD Player Recognition and Connection

    When I insert a DVD into the built-in Toshiba DVD Player in my laptop, a message comes up saying that the drive is not found or recognized.  It is not listed in the device manager listing in the Control Panel either.  How do I get this drive recogniz

  • Patching the database

    Hello, I just entered metalink to download some patches to update my database (I have 11.1.0.7.0). I found an patch set to update to 11.1.0.7.4 at least and want to install it. When I need to choose for which platform to download it to I cannot find

  • [CS2/CS3] - PMString & string builder

    Hello,    I am using a class called PMString for creating strings such as a logs and so on. If I have larger file there is a problem with realocation of PMString, it is the same line String and StringBuilder in .NET languages. Please is there way to