<div dir="ltr">The main usage of gdalinfo is manual inspection of the image. It was not intended for use within other scripts. The output is formatted for human reading.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Mar 5, 2013 at 9:00 PM, Caleb Hanger <span dir="ltr"><<a href="mailto:cdhanger@gmail.com" target="_blank">cdhanger@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Mar 05, 2013 at 01:31:01PM +0530, Chaitanya kumar CH wrote:<br>
> On Tue, Mar 5, 2013 at 11:53 AM, Caleb Hanger <<a href="mailto:cdhanger@gmail.com">cdhanger@gmail.com</a>> wrote:<br>
</div><div class="im">> > What do you mean?  The histogram is only precomputed if gdalinfo has been<br>
> > run previously and stored a cache of data (the XML file) for later<br>
> > reference; please correct me if I'm wrong.  Otherwise, it seems to me that<br>
> > the data *must* be analyzed and the data computed; there is no way around<br>
> > that.  Additionally, I don't think it makes sense to say that it is faster<br>
> > to assemble a histogram that includes out-of-range values than to assemble<br>
> > a histogram that does not, because the latter is a subset contained within<br>
> > the former.<br>
> ><br>
> Some raster formats can store the histogram data as metadata. Also, there<br>
> are is a shortcut; overviews can be used to get approximate values faster.<br>
<br>
</div>Understood, thanks for pointing that out.  In that case, however, the responsibility to decide whether to include out-of-range values lies in the raster format, correct?<br>
<div class="im"><br>
> You can write a simple python script to get the histogram. You can get a<br>
> good idea at<br>
> <a href="http://trac.osgeo.org/gdal/browser/trunk/autotest/gcore/histogram.py#L103" target="_blank">http://trac.osgeo.org/gdal/browser/trunk/autotest/gcore/histogram.py#L103</a><br>
<br>
</div>Right, of course I can construct my own utility to include the GDAL libraries and call GetHistogram in the manner I'd like, and I will probably end up doing so, but in C.  My main goal at the moment is a bash shell script that accomplishes a bigger task, so with a Python script I'd still have to call out to the Python script externally.  Either language would be suited well for the smaller purpose of getting and analyzing the histogram.  I merely found it odd that gdalinfo does not allow the user to disable an option that just doesn't seem to make sense for most applications.<br>

<div class="im"><br>
> > Yes: quite simply, a histogram that does not include illegitimate values<br>
> > makes more sense than a histogram that does include them.  At least, this<br>
> > is the case in my experience; perhaps there are situations I'm unfamiliar<br>
> > with in which the histogram is desired to include values outside of the<br>
> > histogram's range, for some reason.  I'd even go so far as to say that<br>
> > gdalinfo currently *lies* about the histogram, telling the user that the<br>
> > histogram shows "256 buckets from X to Y" even though the histogram<br>
> > includes values which are *outside of that range*.<br>
> ><br>
> > Arguably an even better justification is that the machinery to exclude the<br>
> > illegitimate values is already present in GetHistogram, so *very* few lines<br>
> > of code would need to be added to gdalinfo, simply to provide a flag for<br>
> > the user and if that flag is specified, pass "false" for the right<br>
> > parameter to GetHistogram (bIncludeOutOfRange), instead of just calling<br>
> > GetDefaultHistogram.<br>
> ><br>
><br>
> That sounds reasonable. If you can, you should submit a patch or a request<br>
> at <a href="http://trac.osgeo.org/gdal/newticket" target="_blank">http://trac.osgeo.org/gdal/newticket</a><br>
> Note that the functionality should include the facility to include options<br>
> to mention the min/max values.<br>
<br>
</div>Thanks; I will post a patch when I have a chance.  When requesting a histogram in gdalinfo, the min/max values are already mentioned, and this will just be an addition to, and modification of, that functionality.<br>

<div class="HOEnZb"><div class="h5">_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br><br>+91-9494447584<br>17.2416N 80.1426E
</div>