001/** 002 * 003 */ 004package plugins.kernel.roi.descriptor.intensity; 005 006import icy.roi.ROI; 007import icy.roi.ROIDescriptor; 008import icy.sequence.Sequence; 009import icy.sequence.SequenceEvent; 010import icy.sequence.SequenceEvent.SequenceEventSourceType; 011 012/** 013 * Minimum intensity ROI descriptor class (see {@link ROIDescriptor}) 014 * 015 * @author Stephane 016 */ 017public class ROIMinIntensityDescriptor extends ROIDescriptor 018{ 019 public static final String ID = "Min intensity"; 020 021 public ROIMinIntensityDescriptor() 022 { 023 super(ID, "Min Intensity", Double.class); 024 } 025 026 @Override 027 public String getDescription() 028 { 029 return "Minimum intensity"; 030 } 031 032 @Override 033 public boolean separateChannel() 034 { 035 return true; 036 } 037 038 @Override 039 public boolean needRecompute(SequenceEvent change) 040 { 041 return (change.getSourceType() == SequenceEventSourceType.SEQUENCE_DATA); 042 } 043 044 @Override 045 public Object compute(ROI roi, Sequence sequence) throws UnsupportedOperationException 046 { 047 return Double.valueOf(computeMinIntensity(roi, sequence)); 048 } 049 050 /** 051 * Computes and returns the minimum intensity for the specified ROI on given sequence.<br> 052 * It may returns <code>Double.Nan</code> if the operation is not supported for that ROI. 053 * 054 * @param roi 055 * the ROI on which we want to compute the minimum intensity 056 * @param sequence 057 * the sequence used to compute the pixel intensity 058 * @throws UnsupportedOperationException 059 * if the operation is not supported for this ROI 060 */ 061 public static double computeMinIntensity(ROI roi, Sequence sequence) throws UnsupportedOperationException 062 { 063 try 064 { 065 return ROIIntensityDescriptorsPlugin.computeIntensityDescriptors(roi, sequence, false).min; 066 } 067 catch (Exception e) 068 { 069 throw new UnsupportedOperationException(ROIMinIntensityDescriptor.class.getSimpleName() + ": cannot compute descriptors for '" 070 + roi.getName() + "'", e); 071 } 072 } 073}