Skip to content

Commit

Permalink
Get channel histogram bounds at once and then filter (instead of the …
Browse files Browse the repository at this point in the history
…opposite)
  • Loading branch information
urubens committed Jan 6, 2022
1 parent 9e92043 commit 61b9ee0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pims/api/histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 61b9ee0

Please sign in to comment.