예제 #1
0
/** 
 * @brief Copy input color image to ouput image, with respect to mask image
 * @param imIn : input color image
 * @param imMask : mask image
 * @param [out] imOut : output color image
 */
template<typename Tin, typename Tmask, typename Tout> void ImCopy(const DipImage<Tin> & imIn, const DipImage<Tmask> & imMask, DipImage<Tout> & imOut)
{
	dbi.WriteEnter("Entering ImCopy_WithMask\n");
	//~ const int w = imIn.width(), h = imIn.height();
	//~ for(int i = 0; i < w; i++){
		//~ for(int j = 0; j< h; j++){
			//~ if(imMask(i,j) != 255){
				//~ imOut(i,j) = imIn(i,j);
			//~ }
			//~ else{
				//~ imOut(i,j) = 0;
			//~ }
		//~ }
	//~ }
	if (sizeof(Tin) <= sizeof(Tout)){
		const Tin * p_in = &imIn(0,0);
		const Tin * p_inend = p_in + imIn.width() * imIn.height();
		const Tmask * p_mask = &imMask(0,0);
		Tout * p_out = &imOut(0,0);
		for (; p_in != p_inend; p_in++, p_out++, p_mask++){
			if (*p_mask != 0){
				*p_out = Tout(*p_in);
			}
		}
	}
	dbi.WriteOut("Leaving ImCopy_WithMask\n");
}
예제 #2
0
/** 
 * @brief Copy input color image to ouput image, with respect to mask image
 * @param imIn : input color image
 * @param [out] imOut : output color image
 */
template<typename Tin,typename Tout> void ImCopy(const DipColorImage<Tin> & imIn, DipColorImage<Tout> & imOut)
{
	dbi.WriteEnter("Entering ImCopy_WithMask\n");	
	DipImage<uchar> imMask(imIn.width(), imIn.height());
	imMask.init(255);
	ImCopy(imIn, imMask, imOut);
	dbi.WriteOut("Leaving ImCopy_WithMask\n");
}
예제 #3
0
/** 
 * @brief Copy input color image to ouput image, with respect to mask image
 * @param imIn : input color image
 * @param imMask : mask image
 * @param [out] imOut : output color image
 */
template<typename Tin, typename Tmask, typename Tout> void ImCopy(const DipColorImage<Tin> & imIn, const DipImage<Tmask> & imMask, DipColorImage<Tout> & imOut)
{
	dbi.WriteEnter("Entering ImCopy_WithMask\n");
	const int w = imIn.width(), h = imIn.height();
	if (sizeof(Tin) <= sizeof(Tout)){
		imOut.init(0);
		for(int i = 0 ;i < w;i++){
			for(int j = 0;j < h;j++){
				if(imMask(i,j) !=0){
					imOut(i,j)[0] = Tout(imIn(i,j)[0]);
					imOut(i,j)[1] = Tout(imIn(i,j)[1]);
					imOut(i,j)[2] = Tout(imIn(i,j)[2]);
				}
					
			}
		}
	}
	dbi.WriteOut("Leaving ImCopy_WithMask\n");
}