Radio buttons for Original/RGB/HSV/YUV images
484093
def initUI(self):

        #self.setMinimumSize(WIDTH,HEIGTH)
        #self.setMaximumSize(WIDTH,HEIGTH)

        ''''''
        self.origButton = QRadioButton("Original")
        self.rgbButton = QRadioButton("RGB")
        self.hsvButton = QRadioButton("HSV")
        self.yuvButton = QRadioButton("YUV")
        '''HSV status scheck'''
        self.hsvCheck = QCheckBox('HSV Color Disc')
        self.hsvCheck.setObjectName("hsvCheck")
        self.hsvCheck.stateChanged.connect(self.showHSVWidget)

        '''Signals for toggled radio buttons'''
        self.origButton.toggled.connect(lambda:self.origButtonState())       
        self.rgbButton.toggled.connect(lambda:self.rgbButtonState())
        self.hsvButton.toggled.connect(lambda:self.hsvButtonState())
        self.yuvButton.toggled.connect(lambda:self.yuvButtonState())

        self.origButton.setChecked(True)

        '''Main layout of the widget will contain several vertical layouts'''
        self.gLayout = QGridLayout(self)
        self.gLayout.setObjectName("gLayout")

        ''' Vertical Layout for radio buttons '''
        self.radio1Layout = QHBoxLayout()
        self.radio2Layout = QVBoxLayout()
        self.radio3Layout = QVBoxLayout()
        self.radioLayout = QVBoxLayout()
        self.radioLayout.setObjectName("radioLayout")
        self.radio1Layout.addWidget(self.origButton)
        self.radio1Layout.addWidget(self.rgbButton)
        self.radio1Layout.addWidget(self.hsvButton)
        self.radio1Layout.addWidget(self.yuvButton)
        self.radio1Layout.addWidget(self.hsvCheck)
        #self.radio1Layout.addLayout(self.radio2Layout)
        #self.radio1Layout.addLayout(self.radio3Layout)
        self.radioLayout.addLayout(self.radio1Layout)
        self.vSpacer = QSpacerItem(10, 10, QSizePolicy.Ignored, QSizePolicy.Ignored);
        self.radioLayout.addItem(self.vSpacer)
        
        hmin,smin,vmin = HSVMIN
        hmax,smax,vmax = HSVMAX
        ''' Vertical Layout for HMIN Slider''' 
        self.hminLayout = QVBoxLayout()
        self.hminLayout.setObjectName("hminLayout")
        self.hminLabel = QLabel("HMin")
        self.hminValue = QLineEdit(str(hmin),self)
        self.hminValue.setValidator(QIntValidator(hmin, hmax, self));
        self.hminValue.setFixedWidth(40)
        self.hminValue.setFixedHeight(27)
        self.hminValue.setAlignment(Qt.AlignCenter);
        self.hminSlider = QSlider(Qt.Vertical)
        self.hminSlider.setMinimum(hmin)
        self.hminSlider.setMaximum(hmax)
        self.hminSlider.setValue(hmin)
        self.hminLayout.addWidget(self.hminLabel, Qt.AlignCenter)
        self.hminLayout.addWidget(self.hminValue,Qt.AlignCenter)
        self.hminLayout.addWidget(self.hminSlider)
        

        ''' Vertical Layout for HMAX Slider''' 
        self.hmaxLayout = QVBoxLayout()
        self.hmaxLayout.setObjectName("hmaxLayout")
        self.hmaxLabel = QLabel("HMax")
        self.hmaxValue = QLineEdit(str(hmax),self)
        self.hmaxValue.setValidator(QIntValidator(hmin, hmax, self));
        self.hmaxValue.setFixedWidth(40)
        self.hmaxValue.setFixedHeight(27)
        self.hmaxValue.setAlignment(Qt.AlignCenter);
        self.hmaxSlider = QSlider(Qt.Vertical)
        self.hmaxSlider.setMinimum(hmin)
        self.hmaxSlider.setMaximum(hmax)
        self.hmaxSlider.setValue(hmax)
        self.hmaxLayout.addWidget(self.hmaxLabel)
        self.hmaxLayout.addWidget(self.hmaxValue)
        self.hmaxLayout.addWidget(self.hmaxSlider)

        ''' Vertical Layout for SMIN Slider'''
        self.sminLayout = QVBoxLayout()
        self.sminLayout.setObjectName("sminLayout")
        self.sminLabel = QLabel("SMin")
        self.sminValue = QLineEdit(str(smin),self)
        self.sminValue.setValidator(QIntValidator(smin, smax, self));
        self.sminValue.setFixedWidth(40)
        self.sminValue.setFixedHeight(27)
        self.sminValue.setAlignment(Qt.AlignCenter);
        self.sminSlider = QSlider(Qt.Vertical)
        self.sminSlider.setMinimum(smin)
        self.sminSlider.setMaximum(smax)
        self.sminSlider.setValue(smin)
        self.sminLayout.addWidget(self.sminLabel)
        self.sminLayout.addWidget(self.sminValue)
        self.sminLayout.addWidget(self.sminSlider)

        ''' Vertical Layout for SMAX Slider'''
        self.smaxLayout = QVBoxLayout()
        self.smaxLayout.setObjectName("smaxLayout")
        self.smaxLabel = QLabel("SMax")
        self.smaxValue = QLineEdit(str(smax),self)
        self.smaxValue.setValidator(QIntValidator(smin, smax, self));
        self.smaxValue.setFixedWidth(40)
        self.smaxValue.setFixedHeight(27)
        self.smaxValue.setAlignment(Qt.AlignCenter);
        self.smaxSlider = QSlider(Qt.Vertical)
        self.smaxSlider.setMinimum(smin)
        self.smaxSlider.setMaximum(smax)
        self.smaxSlider.setValue(smax)
        self.smaxLayout.addWidget(self.smaxLabel)
        self.smaxLayout.addWidget(self.smaxValue)
        self.smaxLayout.addWidget(self.smaxSlider)

        ''' Vertical Layout for VMIN Slider'''
        self.vminLayout = QVBoxLayout()
        self.vminLayout.setObjectName("vminLayout")
        self.vminLabel = QLabel("VMin")
        self.vminValue = QLineEdit(str(vmin),self)
        self.vminValue.setValidator(QIntValidator(vmin, vmax, self));
        self.vminValue.setFixedWidth(40)
        self.vminValue.setFixedHeight(27)
        self.vminValue.setAlignment(Qt.AlignCenter);
        self.vminSlider = QSlider(Qt.Vertical)
        self.vminSlider.setMinimum(vmin)
        self.vminSlider.setMaximum(vmax)
        self.vminSlider.setValue(vmin)
        self.vminLayout.addWidget(self.vminLabel)
        self.vminLayout.addWidget(self.vminValue)
        self.vminLayout.addWidget(self.vminSlider)

        ''' Vertical Layout for VMAX Slider'''
        self.vmaxLayout = QVBoxLayout()
        self.vmaxLayout.setObjectName("vmaxLayout")
        self.vmaxLabel = QLabel("VMax")
        self.vmaxValue = QLineEdit(str(vmax),self)
        self.vmaxValue.setValidator(QIntValidator(vmin, vmax, self));
        self.vmaxValue.setFixedWidth(40)
        self.vmaxValue.setFixedHeight(27)
        self.vmaxValue.setAlignment(Qt.AlignCenter);
        self.vmaxSlider = QSlider(Qt.Vertical)
        self.vmaxSlider.setMinimum(vmin)
        self.vmaxSlider.setMaximum(vmax)
        self.vmaxSlider.setValue(vmax)
        self.vmaxLayout.addWidget(self.vmaxLabel)
        self.vmaxLayout.addWidget(self.vmaxValue)
        self.vmaxLayout.addWidget(self.vmaxSlider)
    
        '''Adding all the vertical layouts to the main horizontal layout'''
        self.gLayout.addLayout(self.radioLayout,1,0,1,6,Qt.AlignCenter)
        self.gLayout.addLayout(self.hminLayout,2,0,Qt.AlignCenter)
        self.gLayout.addLayout(self.hmaxLayout,2,1,Qt.AlignCenter)
        self.gLayout.addLayout(self.sminLayout,2,2,Qt.AlignCenter)
        self.gLayout.addLayout(self.smaxLayout,2,3,Qt.AlignCenter)
        self.gLayout.addLayout(self.vminLayout,2,4,Qt.AlignCenter)
        self.gLayout.addLayout(self.vmaxLayout,2,5,Qt.AlignCenter)
        self.setLayout(self.gLayout)


        '''Signals for sliders value changes'''
        self.hminSlider.valueChanged.connect(self.changeHmin)     
        self.hmaxSlider.valueChanged.connect(self.changeHmax)
        self.sminSlider.valueChanged.connect(self.changeSmin)     
        self.smaxSlider.valueChanged.connect(self.changeSmax)
        self.vminSlider.valueChanged.connect(self.changeVmin)     
        self.vmaxSlider.valueChanged.connect(self.changeVmax)

        self.hminValue.textChanged.connect(self.changeHmin2)
        self.hmaxValue.textChanged.connect(self.changeHmax2)
        self.sminValue.textChanged.connect(self.changeSmin2)
        self.smaxValue.textChanged.connect(self.changeSmax2)
        self.vminValue.textChanged.connect(self.changeVmin2)
        self.vmaxValue.textChanged.connect(self.changeVmax2)
425674
def set_widgets(self):
        """"""
        self.tvBrowserExposure_selection_changed()

        # Set icon
        exposure = self.parent.step_fc_functions1.selected_value(
            layer_purpose_exposure['key'])
        icon_path = get_image_path(exposure)
        self.lblIconIFCWExposureFromBrowser.setPixmap(QPixmap(icon_path))
212404
public function _convert_raw_css($default_media='') {
		$this->tokens = array();
		$sort_selectors = $this->parser->get_cfg('sort_selectors');
		$sort_properties = $this->parser->get_cfg('sort_properties');

		// important comment section ?
		if (isset($this->css['!'])) {
			$this->parser->_add_token(IMPORTANT_COMMENT, rtrim($this->css['!']), true);
			unset($this->css['!']);
		}

		foreach ($this->css as $medium => $val) {
			if ($sort_selectors)
				ksort($val);
			if (intval($medium) < DEFAULT_AT) {
				// un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
				if (strlen(trim($medium))) {
					$this->parser->_add_token(AT_START, $medium, true);
				}
			} elseif ($default_media) {
				$this->parser->_add_token(AT_START, $default_media, true);
			}

			foreach ($val as $selector => $vali) {
				if ($sort_properties)
					ksort($vali);
				$this->parser->_add_token(SEL_START, $selector, true);

				$invalid = array(
					'*' => array(), // IE7 hacks first
					'_' => array(), // IE6 hacks
					'/' => array(), // IE6 hacks
					'-' => array()  // IE6 hacks
				);
				foreach ($vali as $property => $valj) {
					if (strncmp($property,"//",2)!==0) {
						$matches = array();
						if ($sort_properties && preg_match('/^(\*|_|\/|-)(?!(ms|moz|o\b|xv|atsc|wap|khtml|webkit|ah|hp|ro|rim|tc)-)/', $property, $matches)) {
							$invalid[$matches[1]][$property] = $valj;
						} else {
							$this->parser->_add_token(PROPERTY, $property, true);
							$this->parser->_add_token(VALUE, $valj, true);
						}
					}
				}
				foreach ($invalid as $prefix => $props) {
					foreach ($props as $property => $valj) {
						$this->parser->_add_token(PROPERTY, $property, true);
						$this->parser->_add_token(VALUE, $valj, true);
					}
				}
				$this->parser->_add_token(SEL_END, $selector, true);
			}

			if (intval($medium) < DEFAULT_AT) {
				// un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
				if (strlen(trim($medium))) {
					$this->parser->_add_token(AT_END, $medium, true);
				}
			} elseif ($default_media) {
				$this->parser->_add_token(AT_END, $default_media, true);
			}
		}
	}
413898
public static <T extends ImageGray<T>>
	void rgbToHsv(Planar<T> rgb , Planar<T> hsv ) {
		hsv.reshape(rgb.width,rgb.height,3);

		if( hsv.getBandType() == GrayF32.class ) {
			if(BoofConcurrency.USE_CONCURRENT ) {
				ImplColorHsv_MT.rgbToHsv_F32((Planar<GrayF32>)rgb,(Planar<GrayF32>)hsv);
			} else {
				ImplColorHsv.rgbToHsv_F32((Planar<GrayF32>)rgb,(Planar<GrayF32>)hsv);
			}
		} else {
			throw new IllegalArgumentException("Unsupported band type "+hsv.getBandType().getSimpleName());
		}
	}
889617
def iiif_image_key(obj):
    """"""
    if isinstance(obj, ObjectVersion):
        bucket_id = obj.bucket_id
        version_id = obj.version_id
        key = obj.key
    else:
        bucket_id = obj.get('bucket')
        version_id = obj.get('version_id')
        key = obj.get('key')
    return u'{}:{}:{}'.format(
        bucket_id,
        version_id,
        key,
    )
1117470
def RGB_to_HSV(cobj, *args, **kwargs):
    
    var_R = cobj.rgb_r
    var_G = cobj.rgb_g
    var_B = cobj.rgb_b

    var_max = max(var_R, var_G, var_B)
    var_min = min(var_R, var_G, var_B)

    var_H = __RGB_to_Hue(var_R, var_G, var_B, var_min, var_max)

    if var_max == 0:
        var_S = 0
    else:
        var_S = 1.0 - (var_min / var_max)

    var_V = var_max

    return HSVColor(
        var_H, var_S, var_V)
454224
def _update_color_rgb(self, event=None):
        """"""
        if event is None or event.widget.old_value != event.widget.get():
            r = self.red.get()
            g = self.green.get()
            b = self.blue.get()
            h, s, v = rgb_to_hsv(r, g, b)
            self.hue.set(h)
            self.saturation.set(s)
            self.value.set(v)
            args = (r, g, b)
            if self.alpha_channel:
                args += (self.alpha.get(),)
                self.alphabar.set_color(args)
            hexa = rgb_to_hexa(*args)
            self.hexa.delete(0, "end")
            self.hexa.insert(0, hexa)
            self.square.set_hsv((h, s, v))
            self.bar.set(h)
            self._update_preview()
867386
def rgb2cmy(self, img, whitebg=False):
        """"""
        tmp = img*1.0
        if whitebg:
            tmp = (1.0 - (img - img.min())/(img.max() - img.min()))
        out = tmp*0.0
        out[:,:,0] = (tmp[:,:,1] + tmp[:,:,2])/2.0
        out[:,:,1] = (tmp[:,:,0] + tmp[:,:,2])/2.0
        out[:,:,2] = (tmp[:,:,0] + tmp[:,:,1])/2.0
        return out
1025181
function()
              {
                container.find('td.Radio input').unbind('click', radioClicked);
                currentPreview.unbind('click', currentClicked);
                cancelButton.unbind('click', cancelClicked);
                okButton.unbind('click', okClicked);
                if (settings.window.expandable)
                {
                  iconImage.unbind('click', iconImageClicked);
                  moveBar.unbind('mousedown', moveBarMouseDown);
                  $this.icon = null;
                }
                container.find('.QuickColor').unbind('click', quickPickClicked);
                colorMapDiv = null;
                colorBarDiv = null;
                colorMapL1 = null;
                colorMapL2 = null;
                colorMapL3 = null;
                colorBarL1 = null;
                colorBarL2 = null;
                colorBarL3 = null;
                colorBarL4 = null;
                colorBarL5 = null;
                colorBarL6 = null;
                colorMap.destroy();
                colorMap = null;
                colorBar.destroy();
                colorBar = null;
                colorPicker.destroy();
                colorPicker = null;
                activePreview = null;
                currentPreview = null;
                okButton = null;
                cancelButton = null;
                grid = null;
                commitCallback = null;
                cancelCallback = null;
                liveCallback = null;
                container.html('');
                for (i = 0; i < List.length; i++) if (List[i] == $this) List.splice(i, 1);
              }
681076
public static  <T extends ImageGray<T>>
	void rgbToYuv(Planar<T> rgb , Planar<T> yuv) {
		yuv.reshape(rgb.width,rgb.height,3);

		if( rgb.getBandType() == GrayF32.class ) {
			if (BoofConcurrency.USE_CONCURRENT) {
				ImplColorYuv_MT.rgbToYuv_F32((Planar<GrayF32>) rgb, (Planar<GrayF32>) yuv);
			} else {
				ImplColorYuv.rgbToYuv_F32((Planar<GrayF32>) rgb, (Planar<GrayF32>) yuv);
			}
		} else {
			throw new IllegalArgumentException("Unsupported band type "+rgb.getBandType().getSimpleName());
		}
	}
726229
def overlay(image, color):
    
    width, height = image.size
    im = Image.new("RGBA", (width, height), color)
    preview = Image.alpha_composite(image, im)
    return preview
1001623
def as_rgb(self):
        

        html = self.as_html()

        return (
            int(html[1:3], 16),
            int(html[3:5], 16),
            int(html[5:7], 16)
        )
154037
def _convert_images(self):
        
        self._plain_images = []
        self._colour_map = []
        for image in self._images:
            colour_map = []
            new_image = []
            for line in image.split("\n"):
                new_line = ""
                attributes = (None, None, None)
                colours = []
                while len(line) > 0:
                    match = self._colour_sequence.match(line)
                    if match is None:
                        new_line += line[0]
                        colours.append(attributes)
                        line = line[1:]
                    else:
                        # The regexp either matches:
                        # - 2,3,4 for ${c,a,b}
                        # - 5,6 for ${c,a}
                        # - 7 for ${c}.
                        if match.group(2) is not None:
                            attributes = (int(match.group(2)),
                                          ATTRIBUTES[match.group(3)],
                                          int(match.group(4)))
                        elif match.group(5) is not None:
                            attributes = (int(match.group(5)),
                                          ATTRIBUTES[match.group(6)],
                                          None)
                        else:
                            attributes = (int(match.group(7)), 0, None)
                        line = match.group(8)
                new_image.append(new_line)
                colour_map.append(colours)
            self._plain_images.append(new_image)
            self._colour_map.append(colour_map)
1084082
def filtered_hsv(im, filter_h, filter_s, filter_v, default_col=(255,255,255)):
    

    hsv_im = im.convert('HSV')
    H, S, V = 0, 1, 2
    hsv = hsv_im.split()
    mask_h = hsv[H].point(filter_h)
    mask_s = hsv[S].point(filter_s)
    mask_v = hsv[V].point(filter_v)

    Mdat = []
    for h, s, v in zip(mask_h.getdata(), mask_s.getdata(), mask_v.getdata()):
        Mdat.append(255 if (h and s and v) else 0)

    mask = mask_h
    mask.putdata(Mdat)

    filtered_im = Image.new("RGB", im.size, color=default_col)
    filtered_im.paste(im, None, mask)
    return filtered_im
209607
def get(img, light=False):
    """"""
    cols = gen_colors(img)

    if len(cols) < 6:
        logging.error("colorz failed to generate enough colors.")
        logging.error("Try another backend or another image. (wal --backend)")
        sys.exit(1)

    return adjust(cols, light)
403713
def render_image(self, rgbobj, dst_x, dst_y):
        
        if self.surface is None:
            return
        self.logger.debug("redraw surface")

        # get window contents as an array and store it into the CV surface
        rgb_arr = self.viewer.getwin_array(order=self.rgb_order, dtype=np.uint8)
        # TODO: is there a faster way to copy this array in?
        self.surface[:, :, :] = rgb_arr
519356
def __callback (self, rgb, d):
        '''
        

        '''
        data = Images2Rgbd(rgb, d)

        self.lock.acquire()
        self.data = data
        self.lock.release()