Global Mapper v25.0

Cropping Problem - How to create a script

oz1
oz1 Global Mapper User
edited October 2013 in Global Mapper Forum Website
I have a series of georeferenced overlapping aerial photos along a transect.

Each photo contains an area (all in the same place on each photo) where part of the aircraft fuselage was in the edge of the frame. I want to crop out that area. Unfortunately, it is a diagonal feature so I need to create a polygon to crop it out.

Because the images are georeferenced, I would need to create a separate polygon for each one if the polygon has to be specified in the georeferenced coordinates (which will take forever). However, if I could specify a polygon in pixel, line coordinates, I could use the same polygon on every image.

Is there a way to do this and then export the new image in the original georeferenced coordinates?

Unfortunately, the area I want to crop out includes both the upper & lower left part of the image so the image origin (i georeferenced coords) will change with cropping.

Ideally, I want to write a script to do this as I have several hundred images to deal with?

Comments

  • kbellis
    kbellis Global Mapper User Trusted User
    edited October 2013
    Could you post three of the overlapping images to see this more clearly?

    Also, why do you want to crop them in the first place? If there's sufficient overlap, such unwanted intrusions shouldn't matter depending on your software and what your ultimate plans are for these images - also unclear.

    Do you plan on inserting something in place of the aircraft in each photo?

    In any event, I'm thinking maybe an approach through masking might be explored, for example creating action in Photoshop for batch processing entire file folders at a time, or your stitching software may already feature that ability to mask out unwanted bits ahead of control point generation / optimization, blending and stitching.
  • oz1
    oz1 Global Mapper User
    edited October 2013
    Capture.JPG

    Here's an example from two overlapping images. Problem is the black, white & grey area on the left hand side of each image.
  • kbellis
    kbellis Global Mapper User Trusted User
    edited October 2013
    oz1,

    First - Consider starting a new thread in the proper forum, either

    Raster Data

    or

    GM Script Language

    This thread may easily be overlooked since it is in a category which has to do with this website overall and not a specific aspect of Global Mapper.


    Second thing - including actual examples of the data you're wrangling with will give others a chance to try and solve your issue.


    Giving your readers an idea as to why you're doing this, with what tools you have at hand and what your final goal is may also help you in getting the answers you need.

    Kelly
  • global_mapper
    global_mapper Administrator
    edited October 2013
    You can crop to a particular rectangular pixel boundary for a bunch of selected images. Is the pixel boundary rectangular for each image or is it the same polygon in pixel coordinates? If it's rectangular you can load all of the layers and go to the Cropping tab of the Options dialog with them selected and set up cropping to the given number of pixels off of each side. You can also script this.

    If it's the same polygon in pixel boundaries for each one I could maybe update the cropping from a script to allow specifying a crop polygon as pixel coordinates. If you had a couple of sample files and the pixel crop polygon to test with that would help.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • oz1
    oz1 Global Mapper User
    edited October 2013
    .

    If it's the same polygon in pixel boundaries for each one I could maybe update the cropping from a script to allow specifying a crop polygon as pixel coordinates. If you had a couple of sample files and the pixel crop polygon to test with that would help.

    Yes, it's the same polygon (in pixel boundaries) for each one but it's not rectangular so if you could update cropping from a script, that would be wonderful. I'll email a couple of sample files & a polygon later today.

    Many thanks
  • global_mapper
    global_mapper Administrator
    edited October 2013
    I have completed adding support for specifying a crop polygon in pixel coordinates rather than native layer coordinates. To do so provide pixel coordinates in the DEFINE_SHAPE command in the workspace/script, then add CLIP_COLLAR_POLY_PIXEL=YES to the IMPORT command. Here is a short sample doing this when loading a TIF file:

    DEFINE_SHAPE SHAPE_NAME="CUSTOM_CROP_POLY"
    50,50
    4000,500
    4200,6000
    300,5000
    END_DEFINE_SHAPE

    IMPORT FILENAME="C:\temp\export test\O39094A3_bluespringsMO.tif" TYPE="GEOTIFF" LABEL_FIELD_FORCE_OVERWRITE="NO" \
    SAMPLING_METHOD="NEAREST_NEIGHBOR" AUTO_CONTRAST="NO" CONTRAST_SHARED="YES" CONTRAST_MODE="NONE" \
    CLIP_COLLAR="POLY" CLIP_COLLAR_POLY="CUSTOM_CROP_POLY" CLIP_COLLAR_POLY_PIXEL="YES" TEXTURE_MAP="NO"

    I have placed a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v15.xx installation folder to give it a try. If you are using the 64-bit v15 version there is a new build at http://www.bluemarblegeo.com/downloads/global-mapper/global_mapper15_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
  • oz1
    oz1 Global Mapper User
    edited October 2013
    I have completed adding support for specifying a crop polygon in pixel coordinates rather than native layer coordinates.
    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation

    That's great Mike & what a lightning response. Many thanks.