diff --git a/pims/api/histograms.py b/pims/api/histograms.py index 7b2143d..e79402f 100644 --- a/pims/api/histograms.py +++ b/pims/api/histograms.py @@ -12,6 +12,7 @@ # * See the License for the specific language governing permissions and # * limitations under the License. import itertools +import operator from typing import List, Optional from fastapi import APIRouter, BackgroundTasks, Depends, Query, Response @@ -25,7 +26,7 @@ ) from pims.api.utils.models import CollectionSize, HistogramType from pims.api.utils.parameter import imagepath_parameter -from pims.api.utils.response import response_list +from pims.api.utils.response import CustomOrJsonResponse, response_list from pims.files.file import HISTOGRAM_STEM, Path from pims.processing.histograms.utils import argmax_nonzero, argmin_nonzero, build_histogram_file from pims.utils.iterables import ensure_list @@ -219,6 +220,10 @@ def show_channels_histogram( histograms = [] n_bins = parse_n_bins(hist_config.n_bins, len(in_image.value_range)) htype = in_image.histogram_type() + + # hist_filter = operator.itemgetter(*channels) + # channels_bounds = hist_filter(in_image.channels_bounds()) + # channels_histograms = hist_filter(in_image.channel_histogram()) TODO for channel in channels: histograms.append( ChannelHistogram( @@ -256,8 +261,10 @@ def show_channels_histogram_bounds( hist_info = [] htype = in_image.histogram_type() - for channel in channels: - mini, maxi = in_image.channel_bounds(channel) + hist_filter = operator.itemgetter(*channels) + channels_bounds = hist_filter(in_image.channels_bounds()) + for channel, bounds in zip(channels, channels_bounds): + mini, maxi = bounds hist_info.append( ChannelHistogramInfo( channel=channel, type=htype,