<div dir="ltr">Caleb,<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 5, 2013 at 11:53 AM, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">On Tue, Mar 05, 2013 at 11:19:27AM +0530, Chaitanya kumar CH wrote:<br>
<br>
> Caleb,<br>
><br>
> gdalinfo uses the GetDefaultHistogram() method which can do this faster by<br>
> fetching a precomputed histogram.<br>
<br>
</div>What do you mean? The histogram is only precomputed if gdalinfo has been run previously and stored a cache of data (the XML file) for later reference; please correct me if I'm wrong. Otherwise, it seems to me that the data *must* be analyzed and the data computed; there is no way around that. Additionally, I don't think it makes sense to say that it is faster to assemble a histogram that includes out-of-range values than to assemble a histogram that does not, because the latter is a subset contained within the former.<br>
</blockquote><div>Some raster formats can store the histogram data as metadata. Also, there are is a shortcut; overviews can be used to get approximate values faster.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div> </div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im">
> gdalinfo is a command line program. Even a default histogram of 256 buckets<br>
> is hard to visualize in text mode. A much better way is to use a desktop<br>
> GIS like qgis to view the histogram.<br>
<br>
</div>A desktop GIS is not practical for providing a shell script meant to automate a repetitive (and much larger) task, with a small chunk of data that it needs for a single step in the process. That is, I don't need to "visualize" the data -- I just need to get the information. The more primitive the format, the better, as I like things that are lean and mean, and I know how to instruct the script to do the required mathematics upon the text-only histogram.<br>
</blockquote><div>You can write a simple python script to get the histogram. You can get a good idea at <a href="http://trac.osgeo.org/gdal/browser/trunk/autotest/gcore/histogram.py#L103">http://trac.osgeo.org/gdal/browser/trunk/autotest/gcore/histogram.py#L103</a><br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
> Can you justify adding this extra functionality in gdalinfo?<br>
<br>
</div>Yes: quite simply, a histogram that does not include illegitimate values makes more sense than a histogram that does include them. At least, this is the case in my experience; perhaps there are situations I'm unfamiliar with in which the histogram is desired to include values outside of the histogram's range, for some reason. I'd even go so far as to say that gdalinfo currently *lies* about the histogram, telling the user that the histogram shows "256 buckets from X to Y" even though the histogram includes values which are *outside of that range*.<br>
<br>
Arguably an even better justification is that the machinery to exclude the illegitimate values is already present in GetHistogram, so *very* few lines of code would need to be added to gdalinfo, simply to provide a flag for the user and if that flag is specified, pass "false" for the right parameter to GetHistogram (bIncludeOutOfRange), instead of just calling GetDefaultHistogram.<br>
</blockquote><div> </div><div>That sounds reasonable. If you can, you should submit a patch or a request at <a href="http://trac.osgeo.org/gdal/newticket">http://trac.osgeo.org/gdal/newticket</a><br></div><div>Note that the functionality should include the facility to include options to mention the min/max values.<br>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class=""><div class="h5"><br>
> On Tue, Mar 5, 2013 at 10:56 AM, Caleb Hanger <<a href="mailto:cdhanger@gmail.com">cdhanger@gmail.com</a>> wrote:<br>
><br>
> > All,<br>
> ><br>
> > I am writing a script which is calling gdalinfo to get a histogram of<br>
> > pixel values in an image file. Apparently the mechanism for obtaining a<br>
> > "default" histogram enables the "bIncludeOutOfRange" flag to dump<br>
> > not-in-range pixels (including null pixels, in formats that support it)<br>
> > into whichever bin of the histogram is closest. I see that in the<br>
> > GetHistogram() function, the functionality is already coded to respond<br>
> > appropriately to either a true *or* false value in this flag. However, I<br>
> > can't seem to find any way to turn that flag off through any of the<br>
> > user-level programs (in particular, gdalinfo), rendering the parameter to<br>
> > the function useless, unless I'm just not looking hard enough. Hence, my<br>
> > questions:<br>
> ><br>
> > 1) Is there any standard user-level operation (preferably in gdalinfo)<br>
> > which disables, or at least *allows* for disabling of, the<br>
> > bIncludeOutOfRange flag? If so, I can't find it.<br>
> > 2) If not, how come? Has there been no apparent need for histograms that<br>
> > omit null values or other "out of range" situations?<br>
> ><br>
> > Thanks in advance for any insight,<br>
> > Caleb Hanger<br>
> > _______________________________________________<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>
> ><br>
><br>
><br>
><br>
> --<br>
> Best regards,<br>
> Chaitanya kumar CH.<br>
><br>
> <a href="tel:%2B91-9494447584" value="+919494447584">+91-9494447584</a><br>
> 17.2416N 80.1426E<br>
_______________________________________________<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></div></div>