You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Lucas (JIRA)" <ji...@apache.org> on 2012/10/14 05:54:02 UTC

[jira] [Created] (IMAGING-94) Add ability to load partial TIFF images

Gary Lucas created IMAGING-94:
---------------------------------

             Summary: Add ability to load partial TIFF images
                 Key: IMAGING-94
                 URL: https://issues.apache.org/jira/browse/IMAGING-94
             Project: Commons Imaging
          Issue Type: New Feature
          Components: Format: TIFF
            Reporter: Gary Lucas


For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.

I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.

These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.

The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer(x));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer(y));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Lucas updated IMAGING-94:
------------------------------

    Description: 
For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.

I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.

These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.

The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));


  was:
For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.

I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.

These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.

The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
{{monospaced}}
bq
        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));


    
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483513#comment-13483513 ] 

Gary Lucas commented on IMAGING-94:
-----------------------------------

Good idea.  The only reason I didn't use arraycopy was that I didn't think of it.

I just ran a quick test using both approaches and it does actually seem to make much difference. System.arraycopy is actually about 0.1 percent slower. But on my computer there is so much other stuff running that it makes for a noisy testing environment, and that value is probably not statistically significant.

Given that the run times are so close, I am inclined to replace the code with the System.arraycopy call just for the sake of simplicity...   No sense adding complicated loops that you have to explain to people when a simple System method call works just as well and brings clarity to the code.
                
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>         Attachments: LucasTrackerItem94_Oct14.patch
>
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Lucas updated IMAGING-94:
------------------------------

    Description: 
For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.

I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.

These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.

The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
{{monospaced}}
bq
        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));


  was:
For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.

I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.

These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.

The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:

        HashMap<String, Object> params = new HashMap<String, Object>();

        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer(x));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer(y));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
        params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));


    
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
> {{monospaced}}
> bq
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Damjan Jovanovic (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483490#comment-13483490 ] 

Damjan Jovanovic commented on IMAGING-94:
-----------------------------------------

Hi Gary

Wow what a patch :).

In this section, is there some reason you don't use System.arraycopy()? That should be even faster than looping and copying 2 values at a time.

{code}
+        // Transcribe the data.  In this code block, there is a small
+        // amount of loop unrolling.  In testing, unrolling saves about 25 
+        // percent load time for large subimages.  2/3 of the cost of reading
+        // the subimage is in the transcription of data.
+        int[] argb = new int[w * h];
+        int k = 0;
+        int w2 = w / 2;
+        for (int iRow = 0; iRow < h; iRow++) {
+            int dIndex = (iRow + y) * width + x;
+            for (int j = 0; j < w2; j++) {
+                argb[k++] = this.data[dIndex++];
+                argb[k++] = this.data[dIndex++];
+            }
+            if ((w & 1) != 0) {
+                // there's an odd number of columns
+                argb[k++] = this.data[dIndex++];
+            }
+        }
{code}
                
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>         Attachments: LucasTrackerItem94_Oct14.patch
>
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Lucas updated IMAGING-94:
------------------------------

    Attachment: LucasTrackerItem94_Oct14.patch

This patch implements the new features.  I would like to thank my employer, Sonalysts, Inc. for sponsoring this work and giving me permission to contribute it to the Apache Commons Imaging project
                
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>         Attachments: LucasTrackerItem94_Oct14.patch
>
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Lucas updated IMAGING-94:
------------------------------

    Attachment: LucasTrackerItem94_Oct24.patch

This 24 October patch uses the System.arraycopy method as recommended by Damjan.  I have tested it several ways and believe that it is ready for incorporation into the code tree.
                
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>         Attachments: LucasTrackerItem94_Oct14.patch, LucasTrackerItem94_Oct24.patch
>
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Comment Edited] (IMAGING-94) Add ability to load partial TIFF images

Posted by "Gary Lucas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IMAGING-94?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483513#comment-13483513 ] 

Gary Lucas edited comment on IMAGING-94 at 10/24/12 7:44 PM:
-------------------------------------------------------------

Good idea.  The only reason I didn't use arraycopy was that I didn't think of it.

I just ran a quick test using both approaches and it doesn't actually seem to make much difference. System.arraycopy is actually about 0.1 percent slower. But on my computer there is so much other stuff running that it makes for a noisy testing environment, and that value is probably not statistically significant.

Given that the run times are so close, I am inclined to replace the code with the System.arraycopy call just for the sake of simplicity...   No sense adding complicated loops that you have to explain to people when a simple System method call works just as well and brings clarity to the code.
                
      was (Author: gwlucas):
    Good idea.  The only reason I didn't use arraycopy was that I didn't think of it.

I just ran a quick test using both approaches and it does actually seem to make much difference. System.arraycopy is actually about 0.1 percent slower. But on my computer there is so much other stuff running that it makes for a noisy testing environment, and that value is probably not statistically significant.

Given that the run times are so close, I am inclined to replace the code with the System.arraycopy call just for the sake of simplicity...   No sense adding complicated loops that you have to explain to people when a simple System method call works just as well and brings clarity to the code.
                  
> Add ability to load partial TIFF images
> ---------------------------------------
>
>                 Key: IMAGING-94
>                 URL: https://issues.apache.org/jira/browse/IMAGING-94
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>            Reporter: Gary Lucas
>         Attachments: LucasTrackerItem94_Oct14.patch
>
>
> For most Apache Commons Imaging applications, the easiest way to obtain a sub image from a file is to simply use the Imaging class to load it as a BufferedImage and then use BufferedImage’s getSubimage() method to extract the portion of the image you wish to use.  The TIFF format presents a special problem because it is very common to have huge images (100’s or even 1000’s of megapixel).  Examples include Landsat satellite images, global-scale GeoTIFF images, etc.  In such cases, loading the entire image into memory is not practical because it would require too much memory.  For example, I am currently working with a 21600 by 10800 image that requires more than 890 megabytes to store as a BufferedImage.  That value is pushing the limit of what I can configure Java to handle on my particular OS.
> I propose to implement features for TIFF files that would permit Commons Imaging to load a partial image of a TIFF file using only the amount memory actually needed to hold the sub-image.
> These changes would not interfere with normal operations of TIFF files and would not affect other image formats.  If there were a need for similar features for other image formats, they could be phased in through future changes.
> The specification for a sub-image would be through the use of the params argument in the getBufferedImage call as follows:
>         HashMap<String, Object> params = new HashMap<String, Object>();
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, new Integer( x ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, new Integer( y ));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, new Integer(width));
>         params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, new Integer(height));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira