www.pudn.com > ImageRe.rar > HsbQuantify.java


package com.image.method; 
 
public class HsbQuantify { 
	public HsbQuantify(){} 
	 
	public int[] convert(float[][] f){ 
		float hue; 
		float sat; 
		float bri; 
		int h=0; 
		int s=0; 
		int v=0; 
		int len=f.length; 
		int[] rs=new int[len]; 
		for(int i=0;i=316){   
				h=0; 
			}else if(hue>=21&hue<=40){ 
				h=1; 
			}else if(hue>=41&hue<=75){ 
				h=2; 
			}else if(hue>=76&hue<=155){ 
				h=3; 
			}else if(hue>=156&hue<=190){ 
				h=4; 
			}else if(hue>=191&hue<=270){ 
				h=5; 
			}else if(hue>=271&hue<=295){ 
				h=6; 
			}else if(hue>=296&hue<=315){ 
				h=7; 
			} 
			 
			sat=f[i][1]; 
			if(sat>=0&sat<0.2){ 
				s=0; 
			}else if(sat>=0.2&sat<0.7){ 
				s=1; 
			}else if(sat>=0.7&sat<=1){ 
				s=2; 
			} 
			 
			bri=f[i][2]; 
			if(bri>=0&bri<0.2){ 
				v=0; 
			}else if(bri>=0.2&bri<0.7){ 
				v=1; 
			}else if(bri>=0.7&bri<=1){ 
				v=2; 
			} 
			//System.out.print(h); 
			rs[i]=9*h+3*s+v; 
		} 
		 
		return rs; 
	} 
	 
	public float[] histo(int[] it){ 
		 
		float[] h=new float[QUANTIFY_HSB_SIZE ]; 
		int[] t=new int[QUANTIFY_HSB_SIZE ];  //temp int[] 
		int len=it.length; 
		for(int i=0;i