예제 #1
0
mlib_status
__mlib_ImageGridWarp_Fp(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_f32 *xWarpPos,
    const mlib_f32 *yWarpPos,
    mlib_d64 postShiftX,
    mlib_d64 postShiftY,
    mlib_s32 xStart,
    mlib_s32 xStep,
    mlib_s32 xNumCells,
    mlib_s32 yStart,
    mlib_s32 yStep,
    mlib_s32 yNumCells,
    mlib_filter filter,
    mlib_edge edge)
{
	mlib_type type;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

	type = mlib_ImageGetType(dst);

	if (type != MLIB_FLOAT && type != MLIB_DOUBLE) {
		return (MLIB_FAILURE);
	}

	return mlib_ImageGridWarp_alltypes(dst, src, xWarpPos, yWarpPos,
	    postShiftX, postShiftY,
	    xStart, xStep, xNumCells, yStart, yStep, yNumCells, filter, edge);
}
mlib_status
__mlib_ImageSubsampleAverage_ty_Fp(
    mlib_image *dst,
    const mlib_image *src,
    mlib_d64 xscale,
    mlib_d64 yscale,
    mlib_s32 ybegin)
{
	mlib_type type;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_TYPE_EQUAL(src, dst);
	MLIB_IMAGE_CHAN_EQUAL(src, dst);

	if (!(xscale > 0 && xscale <= 1 && yscale > 0 && yscale <= 1)) {
		return (MLIB_FAILURE);
	}

	type = mlib_ImageGetType(dst);

	switch (type) {
	case MLIB_FLOAT:
		return mlib_ImageSubsampleAverage_F32_main(dst, src, xscale,
		    yscale, ybegin);
	case MLIB_DOUBLE:
		return mlib_ImageSubsampleAverage_D64_main(dst, src, xscale,
		    yscale, ybegin);
	default:
		break;
	}

	return (MLIB_FAILURE);
}
예제 #3
0
mlib_status
__mlib_ImageDiv_Fp(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2)
{
	mlib_type type = mlib_ImageGetType(dst);

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src1);
	MLIB_IMAGE_CHECK(src2);
	MLIB_IMAGE_FULL_EQUAL(dst, src1);
	MLIB_IMAGE_FULL_EQUAL(dst, src2);

	switch (type) {
	case MLIB_FLOAT:
		mlib_ImageDiv_Fp_F32(dst, src1, src2);
		return (MLIB_SUCCESS);

	case MLIB_DOUBLE:
		mlib_ImageDiv_Fp_D64(dst, src1, src2);
		return (MLIB_SUCCESS);

	default:
		return (MLIB_FAILURE);
	}
}
예제 #4
0
mlib_status
__mlib_ImageDivConstShift(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *consts,
    mlib_s32 shift)
{
	mlib_d64 dalpha[4], dbeta[4], dshift;
	mlib_s32 nchan, k;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_FULL_EQUAL(dst, src);
	nchan = mlib_ImageGetChannels(dst);

	if (shift < 0 || shift > 31)
		return (MLIB_OUTOFRANGE);

	dshift = (1u << shift);
	for (k = 0; k < nchan; k++) {
		dalpha[k] =
		    (consts[k] == 0) ? 2.0 * MLIB_S32_MAX : dshift / consts[k];
		dbeta[k] = 0;
	}

	return (__mlib_ImageScale2(dst, src, dalpha, dbeta));
}
예제 #5
0
mlib_status
__mlib_ImageNotAnd(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2)
{
    MLIB_IMAGE_CHECK(src1);
    MLIB_IMAGE_CHECK(src2);
    MLIB_IMAGE_CHECK(dst);

    if ((mlib_ImageGetType(src1) == MLIB_BYTE) ||
            (mlib_ImageGetType(src1) == MLIB_SHORT) ||
            (mlib_ImageGetType(src1) == MLIB_USHORT) ||
            mlib_ImageGetType(src1) == MLIB_INT) {

        return (mlib_v_ImageLogic(dst, src1, src2));

    } else if (mlib_ImageGetType(src1) == MLIB_BIT) {

        if ((mlib_ImageGetBitOffset(src1) ==
                mlib_ImageGetBitOffset(dst)) &&
                (mlib_ImageGetBitOffset(src2) ==
                 mlib_ImageGetBitOffset(dst))) {
            return (mlib_v_ImageNotAnd_Bit(dst, src1, src2));
        } else {
            return (mlib_ImageNotAnd_Bit(dst, src1, src2));
        }

    } else
        return (MLIB_FAILURE);
}
예제 #6
0
mlib_status
__mlib_ImageConstNotOr(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *c)
{
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

	if ((mlib_ImageGetType(src) == MLIB_BYTE) ||
	    (mlib_ImageGetType(src) == MLIB_SHORT) ||
	    (mlib_ImageGetType(src) == MLIB_USHORT) ||
	    mlib_ImageGetType(src) == MLIB_INT) {

		return (mlib_v_ImageConstLogic(dst, src, c));

	} else if (mlib_ImageGetType(src) == MLIB_BIT) {

		if (mlib_ImageGetBitOffset(src) ==
		    mlib_ImageGetBitOffset(dst)) {
			return (mlib_v_ImageConstNotOr_Bit(dst, src, c));
		} else {
			return (mlib_ImageConstNotOr_Bit(dst, src, c));
		}

	} else
		return (MLIB_FAILURE);
}
예제 #7
0
mlib_status
__mlib_ImageSub(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2)
{
	mlib_type dtype;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src1);
	MLIB_IMAGE_FULL_EQUAL(dst, src1);

	if (src2) {
/*  inplace -> NULL here (U16 case @ UltraIII needs it  */
		MLIB_IMAGE_CHECK(src2);
		MLIB_IMAGE_FULL_EQUAL(dst, src2);
	}

	dtype = mlib_ImageGetType(dst);

	if (dtype == MLIB_BYTE)
		return (mlib_v_ImageSub_U8(dst, src1, src2));
	else if (dtype == MLIB_SHORT)
		return (mlib_v_ImageSub_S16(dst, src1, src2));
	else if (dtype == MLIB_USHORT)
		return (mlib_v_ImageSub_U16(dst, src1, src2));
	else if (dtype == MLIB_INT)
		return (mlib_v_ImageSub_S32(dst, src1, src2));
	else
		return (MLIB_FAILURE);
}
예제 #8
0
mlib_status
__mlib_ImageCopy(
    mlib_image *dst,
    const mlib_image *src)
{
	mlib_s32 s_offset, d_offset, width, height;
	mlib_s32 size, s_stride, d_stride;
	mlib_u8 *sa, *da;
	mlib_s32 j;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_TYPE_EQUAL(src, dst);
	MLIB_IMAGE_CHAN_EQUAL(src, dst);
	MLIB_IMAGE_SIZE_EQUAL(src, dst);

	switch (mlib_ImageGetType(dst)) {
	case MLIB_BIT:

		sa = (mlib_u8 *)mlib_ImageGetData(src);
		da = (mlib_u8 *)mlib_ImageGetData(dst);

		width = mlib_ImageGetWidth(src) * mlib_ImageGetChannels(src);
		height = mlib_ImageGetHeight(src);

		if (!mlib_ImageIsNotOneDvector(src) &&
		    !mlib_ImageIsNotOneDvector(dst)) {
			size = height * (width >> 3);
			mlib_ImageCopy_na(sa, da, size);
		} else {
mlib_status
__mlib_ImageColorConvert1_Fp(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_d64 *fmat)
{
	mlib_s32 slb, dlb, xsize, ysize;
	mlib_type dtype;
	void *sa, *da;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_FULL_EQUAL(dst, src);
	MLIB_IMAGE_HAVE_CHAN(dst, 3);

	if (fmat == NULL)
		return (MLIB_NULLPOINTER);

	dtype = mlib_ImageGetType(dst);
	xsize = mlib_ImageGetWidth(dst);
	ysize = mlib_ImageGetHeight(dst);
	slb = mlib_ImageGetStride(src);
	dlb = mlib_ImageGetStride(dst);
	sa = mlib_ImageGetData(src);
	da = mlib_ImageGetData(dst);

	if (dtype == MLIB_FLOAT) {
		return mlib_ImageColorConvert1_F32(sa, slb / 4,
		    da, dlb / 4, xsize, ysize, fmat);
	} else if (dtype == MLIB_DOUBLE) {
		return mlib_ImageColorConvert1_D64(sa, slb / 8,
		    da, dlb / 8, xsize, ysize, fmat);
	} else
		return (MLIB_FAILURE);
}
예제 #10
0
mlib_status
__mlib_ImageColorRGB2HSL_Fp(
    mlib_image *dst,
    const mlib_image *src)
{
/*  check for obvious errors  */
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_TYPE_EQUAL(dst, src);
	MLIB_IMAGE_CHAN_EQUAL(dst, src);
	MLIB_IMAGE_HAVE_CHAN(dst, 3);

	switch (mlib_ImageGetType(dst)) {
	case MLIB_FLOAT:
		mlib_ImageColorRGB2HSL_Fp_F32(dst, src);
		break;
	case MLIB_DOUBLE:
		mlib_ImageColorRGB2HSL_Fp_D64(dst, src);
		break;
/*  discard any other data types  */
	default:
		return (MLIB_FAILURE);
	}

	return (MLIB_SUCCESS);
}
예제 #11
0
mlib_status mlib_ImageCopy(mlib_image       *dst,
                           const mlib_image *src)
{
  mlib_s32 s_offset, d_offset;
  mlib_s32 size, s_stride, d_stride;
  mlib_s32 width;                                     /* width in bytes of src and dst */
  mlib_s32 height;                                    /* height in lines of src and dst */
  mlib_u8 *sa, *da;
  mlib_s32 j;

  MLIB_IMAGE_CHECK(src);
  MLIB_IMAGE_CHECK(dst);
  MLIB_IMAGE_TYPE_EQUAL(src, dst);
  MLIB_IMAGE_CHAN_EQUAL(src, dst);
  MLIB_IMAGE_SIZE_EQUAL(src, dst);

  switch (mlib_ImageGetType(dst)) {
    case MLIB_BIT:
      width = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst); /* size in bits */
      height = mlib_ImageGetHeight(src);
      sa = (mlib_u8 *) mlib_ImageGetData(src);
      da = (mlib_u8 *) mlib_ImageGetData(dst);

      if (!mlib_ImageIsNotOneDvector(src) && !mlib_ImageIsNotOneDvector(dst)) {
        size = height * (width >> 3);
        if (!mlib_ImageIsNotAligned8(src) && !mlib_ImageIsNotAligned8(dst) && ((size & 7) == 0)) {

          mlib_c_ImageCopy_a1((TYPE_64BIT *) sa, (TYPE_64BIT *) da, size >> 3);
        }
        else {
예제 #12
0
mlib_status mlib_ImageClippingMxN(mlib_image       *dst_i,
                                  mlib_image       *src_i,
                                  mlib_image       *dst_e,
                                  mlib_image       *src_e,
                                  mlib_s32         *edg_sizes,
                                  const mlib_image *dst,
                                  const mlib_image *src,
                                  mlib_s32         kw,
                                  mlib_s32         kh,
                                  mlib_s32         kw1,
                                  mlib_s32         kh1)
{
  mlib_s32  kw2 = kw - 1 - kw1;
  mlib_s32  kh2 = kh - 1 - kh1;
  mlib_s32  src_wid, src_hgt, dst_wid, dst_hgt;
  mlib_s32  dx, dy, dxd, dxs, dyd, dys, wid_e, hgt_e;
  mlib_s32  dx_l, dx_r, dy_t, dy_b, wid_i, hgt_i;

  MLIB_IMAGE_CHECK(dst);
  MLIB_IMAGE_CHECK(src);
  MLIB_IMAGE_TYPE_EQUAL(dst, src);
  MLIB_IMAGE_CHAN_EQUAL(dst, src);

  dst_wid = mlib_ImageGetWidth(dst);
  dst_hgt = mlib_ImageGetHeight(dst);
  src_wid = mlib_ImageGetWidth(src);
  src_hgt = mlib_ImageGetHeight(src);

  /* X clipping */
  dx = src_wid - dst_wid;

  if (dx > 0) {
    dxs = (dx + 1) >> 1;
    dxd = 0;
  } else {
예제 #13
0
mlib_status
__mlib_ImageFlipY_Fp(
    mlib_image *dst,
    const mlib_image *src)
{
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_TYPE_EQUAL(src, dst);
	MLIB_IMAGE_CHAN_EQUAL(src, dst);

	switch (mlib_ImageGetType(src)) {
	case MLIB_FLOAT:
		switch (mlib_ImageGetChannels(src)) {
		case 1:
			mlib_ImageFlipY_S32_1(dst, src);
			break;
		case 2:
			mlib_ImageFlipY_S32_2(dst, src);
			break;
		case 3:
			mlib_ImageFlipY_S32_3(dst, src);
			break;
		case 4:
			mlib_ImageFlipY_S32_4(dst, src);
			break;
		default:
			return (MLIB_FAILURE);
		}

		break;

	case MLIB_DOUBLE:
		switch (mlib_ImageGetChannels(src)) {
		case 1:
			mlib_ImageFlipY_S32_2(dst, src);
			break;
		case 2:
			mlib_ImageFlipY_S32_4(dst, src);
			break;
		case 3:
			mlib_ImageFlipY_D64_3(dst, src);
			break;
		case 4:
			mlib_ImageFlipY_D64_4(dst, src);
			break;
		default:
			return (MLIB_FAILURE);
		}

		break;

	default:
		return (MLIB_FAILURE);
	}

	return (MLIB_SUCCESS);
}
예제 #14
0
mlib_status
__mlib_ImageConstMulShift(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *consts,
    mlib_s32 shift)
{
	mlib_type type;
	void *psrc, *pdst;
	mlib_s32 slb, dlb, xsize, ysize, nchan;
	mlib_s32 beta[4] = { 0, 0, 0, 0 };
	mlib_d64 dalpha[4], dbeta[4], dshift;
	mlib_s32 k;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_FULL_EQUAL(dst, src);

	MLIB_IMAGE_GET_ALL_PARAMS(dst, type, nchan, xsize, ysize, dlb, pdst);
	slb = mlib_ImageGetStride(src);
	psrc = mlib_ImageGetData(src);

	if (shift < 0 || shift > 31)
		return (MLIB_OUTOFRANGE);

/* branch to ImageScale if possible */

	if (type == MLIB_BYTE || type == MLIB_SHORT || type == MLIB_USHORT) {
		if (__mlib_ImageScale(dst, src, consts, beta,
		    shift) == MLIB_SUCCESS)
			return (MLIB_SUCCESS);
	}

	dshift = 1.0 / (1u << shift);
	for (k = 0; k < nchan; k++) {
		dalpha[k] = consts[k] * dshift;
		dbeta[k] = 0;
	}

	if (type == MLIB_BYTE) {

		return (mlib_ImageScale2_U8(dst, src, dalpha, dbeta));
	} else if (type == MLIB_SHORT) {

		return (mlib_ImageScale2_S16(dst, src, dalpha, dbeta));
	} else if (type == MLIB_USHORT) {

		return (mlib_ImageScale2_U16(dst, src, dalpha, dbeta));
	} else if (type == MLIB_INT) {

		return mlib_ImageDConstMul_S32(pdst, psrc, xsize, ysize, nchan,
		    slb / 4, dlb / 4, dalpha);
	}

	return (MLIB_FAILURE);
}
예제 #15
0
mlib_status __mlib_ImageXor(mlib_image *dst,
                            mlib_image *src1,
                            mlib_image *src2)
{
  MLIB_IMAGE_CHECK(src1);
  MLIB_IMAGE_CHECK(src2);
  MLIB_IMAGE_CHECK(dst);

  return mlib_v_ImageLogic(dst, src1, src2);
}
예제 #16
0
mlib_status
__mlib_ImageColorXYZ2RGB(
    mlib_image *dst,
    const mlib_image *src)
{
/* CIE XYZ to Rec709 RGB with D64 White Point */
	mlib_d64 fmat[9] = { 3.240479, -1.537150, -0.498535,
		-0.969256, 1.875992, 0.041566,
		0.055648, -0.204043, 1.057311
	};
	mlib_s32 slb, dlb, xsize, ysize;
	mlib_type dtype;
	mlib_u8 *psrc, *pdst;
	mlib_s32 j;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_FULL_EQUAL(dst, src);

	dtype = mlib_ImageGetType(dst);
	xsize = mlib_ImageGetWidth(dst);
	ysize = mlib_ImageGetHeight(dst);
	dlb = mlib_ImageGetStride(dst);
	pdst = (void *)mlib_ImageGetData(dst);

	slb = mlib_ImageGetStride(src);
	psrc = mlib_ImageGetData(src);

	if (dtype == MLIB_BYTE) {

		for (j = 0; j < ysize; j++) {
			mlib_u8 *ps = psrc,
			    *pd = pdst, *pend = pdst + 3 * xsize;

#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
			for (; pd < pend; pd += 3) {
				MLIB_CONVERT_U8_1(pd, ps);
				ps += 3;
			}

			psrc += slb;
			pdst += dlb;
		}

		return (MLIB_SUCCESS);

	} else {

		return (__mlib_ImageColorConvert1(dst, src, fmat));
	}
}
예제 #17
0
mlib_status
__mlib_ImageSqrShift(
    mlib_image *dst,
    const mlib_image *src,
    mlib_s32 shift)
{
	mlib_type dtype;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_FULL_EQUAL(dst, src);

	dtype = mlib_ImageGetType(dst);

	if (dtype == MLIB_BYTE) {
		if ((shift < 4) || (shift > 11)) {
			return (MLIB_OUTOFRANGE);
		}
	}

	if (dtype == MLIB_SHORT) {
		if ((shift < 1) || (shift > 16)) {
			return (MLIB_OUTOFRANGE);
		}
	}

	if (dtype == MLIB_INT) {
		if ((shift < -1023) || (shift > 1022)) {
			return (MLIB_OUTOFRANGE);
		}
	}

	if (dtype == MLIB_BYTE) {

		return (mlib_c_ImageSqrShift_U8(dst, src, shift));
	} else {

		void *sa = mlib_ImageGetData(src);
		void *da = mlib_ImageGetData(dst);
		mlib_s32 slb = mlib_ImageGetStride(src);
		mlib_s32 dlb = mlib_ImageGetStride(dst);
		mlib_s32 nchan = mlib_ImageGetChannels(src);
		mlib_s32 xsize = mlib_ImageGetWidth(src) * nchan;
		mlib_s32 ysize = mlib_ImageGetHeight(src);

		if (dtype == MLIB_SHORT) {

			mlib_c_ImageSqrShift_S16((mlib_s16 *)sa, (slb >> 1),
			    (mlib_s16 *)da, (dlb >> 1), xsize, ysize, shift);
			return (MLIB_SUCCESS);
		} else if (dtype == MLIB_USHORT) {
예제 #18
0
mlib_status
__mlib_ImageScale(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *alpha,
    const mlib_s32 *beta,
    mlib_s32 shift)
{
	mlib_type stype, dtype;
	mlib_s32 k, nchan;
	mlib_d64 dshift, dalpha[4], dbeta[4];

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_SIZE_EQUAL(dst, src);
	MLIB_IMAGE_CHAN_EQUAL(dst, src);

	if (alpha == NULL)
		return (MLIB_FAILURE);
	if (beta == NULL)
		return (MLIB_FAILURE);
	if (shift < 0 || shift > 31)
		return (MLIB_OUTOFRANGE);

	stype = mlib_ImageGetType(src);
	dtype = mlib_ImageGetType(dst);
	nchan = mlib_ImageGetChannels(dst);

	if (mlib_ImageScale_CheckForVIS(alpha, beta, shift, stype, dtype,
	    nchan) < -1) {
		return (MLIB_OUTOFRANGE);
	}

	dshift = 1.0 / (1u << shift);
	for (k = 0; k < nchan; k++) {
		dalpha[k] = alpha[k] * dshift;
		dbeta[k] = beta[k];
	}

	if (stype == MLIB_BYTE)
		return (mlib_ImageScale2_U8(dst, src, dalpha, dbeta));
	if (stype == MLIB_SHORT)
		return (mlib_ImageScale2_S16(dst, src, dalpha, dbeta));
	if (stype == MLIB_USHORT)
		return (mlib_ImageScale2_U16(dst, src, dalpha, dbeta));
	if (stype == MLIB_INT)
		return (mlib_ImageScale2_S32(dst, src, dalpha, dbeta));

	return (MLIB_FAILURE);
}
예제 #19
0
mlib_status
__mlib_ImageConstNotOr(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *c)
{
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

	if (mlib_ImageGetType(src) == MLIB_BIT) {
		return (mlib_ImageConstNotOr_Bit(dst, src, c));
	}

	return (mlib_m_ImageConstLogic(dst, src, c));
}
예제 #20
0
mlib_status
__mlib_ImageMinimum_Fp(
    mlib_d64 *min,
    const mlib_image *img)
{
/* check for obvious errors */
	MLIB_IMAGE_CHECK(img);

	if (min == NULL)
		return (MLIB_NULLPOINTER);

	switch (mlib_ImageGetType(img)) {
	case MLIB_FLOAT:

		if (mlib_ImageGetChannels(img) == 3)
			mlib_ImageMinimum_F32_3(img, min);
		else
			mlib_ImageMinimum_F32_124(img, min);
		break;

	case MLIB_DOUBLE:

		if (mlib_ImageGetChannels(img) == 3)
			mlib_ImageMinimum_D64_3(img, min);
		else
			mlib_ImageMinimum_D64_124(img, min);
		break;

	default:
		return (MLIB_FAILURE);
	}

	return (MLIB_SUCCESS);
}
예제 #21
0
mlib_status
__mlib_ImageCopyMask_Fp(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_image *mask,
    const mlib_d64 *thresh)
{
	mlib_type dtype;
	mlib_s32 slb, mlb, dlb, xsize, ysize, nchan;
	void *sa, *ma, *da;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(mask);

	MLIB_IMAGE_TYPE_EQUAL(src, dst);
	MLIB_IMAGE_TYPE_EQUAL(mask, dst);

	MLIB_IMAGE_CHAN_EQUAL(src, dst);
	MLIB_IMAGE_CHAN_EQUAL(mask, dst);

	MLIB_IMAGE_SIZE_EQUAL(src, dst);
	MLIB_IMAGE_SIZE_EQUAL(mask, dst);

	dtype = mlib_ImageGetType(dst);
	nchan = mlib_ImageGetChannels(dst);
	xsize = mlib_ImageGetWidth(dst);
	ysize = mlib_ImageGetHeight(dst);
	slb = mlib_ImageGetStride(src);
	mlb = mlib_ImageGetStride(mask);
	dlb = mlib_ImageGetStride(dst);
	sa = mlib_ImageGetData(src);
	ma = mlib_ImageGetData(mask);
	da = mlib_ImageGetData(dst);

	if (dtype == MLIB_FLOAT) {
		mlib_ImageCopyMask_Fp_f32(sa, slb, ma, mlb, da, dlb, xsize,
		    ysize, nchan, thresh);
		return (MLIB_SUCCESS);
	} else if (dtype == MLIB_DOUBLE) {
		mlib_ImageCopyMask_Fp_d64(sa, slb, ma, mlb, da, dlb, xsize,
		    ysize, nchan, thresh);
		return (MLIB_SUCCESS);
	} else
		return (MLIB_FAILURE);
}
예제 #22
0
mlib_status
__mlib_ImageConstAndNot(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *c)
{
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

#ifdef _NO_LONGLONG

	if ((mlib_ImageGetType(src) == MLIB_BYTE) ||
	    (mlib_ImageGetType(src) == MLIB_SHORT) ||
	    (mlib_ImageGetType(src) == MLIB_USHORT)) {

		return (mlib_c_ImageConstLogic(dst, src, c));

	} else if (mlib_ImageGetType(src) == MLIB_BIT) {

		return (mlib_ImageConstAndNot_Bit(dst, src, c));

	} else if (mlib_ImageGetType(src) == MLIB_INT) {

		return (mlib_c_ImageConstLogic_S32(dst, src, c));

	} else
		return (MLIB_FAILURE);

#else /* _NO_LONGLONG */

	if ((mlib_ImageGetType(src) == MLIB_BYTE) ||
	    (mlib_ImageGetType(src) == MLIB_SHORT) ||
	    (mlib_ImageGetType(src) == MLIB_USHORT) ||
	    mlib_ImageGetType(src) == MLIB_INT) {

		return (mlib_c_ImageConstLogic(dst, src, c));

	} else if (mlib_ImageGetType(src) == MLIB_BIT) {

		return (mlib_ImageConstAndNot_Bit(dst, src, c));

	} else
		return (MLIB_FAILURE);
#endif /* _NO_LONGLONG */
}
예제 #23
0
mlib_status
__mlib_ImageRotate270_Fp(
    mlib_image *dst,
    const mlib_image *src)
{
	mlib_type type;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

	type = mlib_ImageGetType(dst);

	if (type != MLIB_FLOAT && type != MLIB_DOUBLE) {
		return (MLIB_FAILURE);
	}

	return (mlib_ImageFlipRotate(dst, src, -1, 0));
}
예제 #24
0
mlib_status mlib_ImageAffine(mlib_image       *dst,
                             const mlib_image *src,
                             const mlib_d64   *mtx,
                             mlib_filter      filter,
                             mlib_edge        edge)
{
  mlib_type type;

  MLIB_IMAGE_CHECK(src);
  MLIB_IMAGE_CHECK(dst);

  type = mlib_ImageGetType(dst);

  if (type != MLIB_BIT && type != MLIB_BYTE &&
      type != MLIB_SHORT && type != MLIB_USHORT && type != MLIB_INT) {
    return MLIB_FAILURE;
  }

  return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge, NULL);
}
예제 #25
0
mlib_status
__mlib_ImageXor(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2)
{
	MLIB_IMAGE_CHECK(src1);
	MLIB_IMAGE_CHECK(src2);
	MLIB_IMAGE_CHECK(dst);

	if ((mlib_ImageGetType(src1) == MLIB_BYTE) ||
	    (mlib_ImageGetType(src1) == MLIB_SHORT) ||
	    (mlib_ImageGetType(src1) == MLIB_USHORT) ||
	    (mlib_ImageGetType(src1) == MLIB_INT)) {

		return (mlib_c_ImageLogic(dst, src1, src2));
	} else if (mlib_ImageGetType(src1) == MLIB_BIT) {
		return (mlib_ImageXor_Bit(dst, src1, src2));
	} else
		return (MLIB_FAILURE);
}
예제 #26
0
mlib_status
__mlib_ImageZoomIndex(
    mlib_image *dst,
    const mlib_image *src,
    mlib_d64 zoomx,
    mlib_d64 zoomy,
    mlib_filter filter,
    mlib_edge edge,
    const void *colormap)
{
	mlib_d64 tx, ty;

	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_CHECK(dst);

	tx = (mlib_ImageGetWidth(dst) - zoomx * mlib_ImageGetWidth(src)) * 0.5;
	ty = (mlib_ImageGetHeight(dst) -
	    zoomy * mlib_ImageGetHeight(src)) * 0.5;

	return __mlib_ImageZoomTranslateIndex(dst, src, zoomx, zoomy, tx, ty,
	    filter, edge, colormap);
}
예제 #27
0
mlib_status
__mlib_ImageOr(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2)
{
	MLIB_IMAGE_CHECK(dst);

	if (mlib_ImageGetType(dst) == MLIB_BIT) {
		return (mlib_ImageOr_Bit(dst, src1, src2));
	}

	return (mlib_m_ImageLogic(dst, src1, src2));
}
예제 #28
0
mlib_status
__mlib_ImageConstSub(
    mlib_image *dst,
    const mlib_image *src,
    const mlib_s32 *c)
{
	mlib_type dtype;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src);
	MLIB_IMAGE_FULL_EQUAL(dst, src);

	if (c == NULL)
		return (MLIB_FAILURE);

	dtype = mlib_ImageGetType(dst);

	if (dtype == MLIB_BYTE) {

		return (mlib_c_ImageConstSub_U8(dst, src, c));

	} else if (dtype == MLIB_SHORT) {

		return (mlib_c_ImageConstSub_S16(dst, src, c));

	} else if (dtype == MLIB_USHORT) {

		return (mlib_c_ImageConstSub_U16(dst, src, c));

	} else if (dtype == MLIB_INT) {

		return (mlib_c_ImageConstSub_S32(dst, src, c));
	}

	return (MLIB_FAILURE);
}
예제 #29
0
mlib_status mlib_ImageConvMxN(mlib_image       *dst,
                              const mlib_image *src,
                              const mlib_s32   *kernel,
                              mlib_s32         m,
                              mlib_s32         n,
                              mlib_s32         dm,
                              mlib_s32         dn,
                              mlib_s32         scale,
                              mlib_s32         cmask,
                              mlib_edge        edge)
{
  MLIB_IMAGE_CHECK(dst);

  switch (mlib_ImageGetType(dst)) {
    case MLIB_BYTE:

      if (scale < 16 || scale > 31)
        return MLIB_FAILURE;
      break;
    case MLIB_SHORT:
    case MLIB_USHORT:

      if (scale < 17 || scale > 32)
        return MLIB_FAILURE;
      break;
    case MLIB_INT:

      if (scale < 0)
        return MLIB_FAILURE;
      break;
    default:
      return MLIB_FAILURE;
  }

  return mlib_ImageConvMxN_f(dst, src, kernel, m, n, dm, dn, scale, cmask, edge);
}
예제 #30
0
mlib_status
__mlib_ImageScalarBlend(
    mlib_image *dst,
    const mlib_image *src1,
    const mlib_image *src2,
    const mlib_s32 *alpha)
{
	mlib_s32 slb1, slb2, dlb, xsize, ysize, nchan;
	mlib_type dtype;
	void *sa1, *sa2, *da;
	mlib_s32 i, j;

	MLIB_IMAGE_CHECK(dst);
	MLIB_IMAGE_CHECK(src1);
	MLIB_IMAGE_CHECK(src2);
	MLIB_IMAGE_FULL_EQUAL(dst, src1);
	MLIB_IMAGE_FULL_EQUAL(dst, src2);

	if (alpha == NULL)
		return (MLIB_FAILURE);
	for (i = 0; i < mlib_ImageGetChannels(dst); i++) {
		if (alpha[i] < 0) {
			return (MLIB_FAILURE);
		}
	}

	MLIB_IMAGE_GET_ALL_PARAMS(dst, dtype, nchan, xsize, ysize, dlb, da);
	slb1 = mlib_ImageGetStride(src1);
	sa1 = mlib_ImageGetData(src1);
	slb2 = mlib_ImageGetStride(src2);
	sa2 = mlib_ImageGetData(src2);

	if (dtype == MLIB_BYTE) {

		mlib_u8 plut[4 * 511], *lut[4], *lutj;
		mlib_s32 res, acc, al;

		for (j = 0; j < nchan; j++) {
/* acc = 0.5 */
			acc = 1 << 22;
/* variable for alpha coefficients */
			al = (alpha[j] & MASK) >> 8;
			lut[j] = lutj = plut + j * 511 + 255;
			lutj[0] = 0;
			for (i = 1; i < 256; i++) {
				acc += al;
				res = acc >> 23;
				lutj[i] = res;
				lutj[-i] = -res;
			}
		}

		switch (nchan) {

		case 1:
			lut[1] = lut[2] = lut[3] = lut[0];
			mlib_c_ImageScalarBlend_U8_124((mlib_u8 *)sa1, slb1,
			    (mlib_u8 *)sa2, slb2, (mlib_u8 *)da, dlb, xsize,
			    ysize, lut);
			break;

		case 2:
			lut[2] = lut[0];
			lut[3] = lut[1];
			mlib_c_ImageScalarBlend_U8_124((mlib_u8 *)sa1, slb1,
			    (mlib_u8 *)sa2, slb2, (mlib_u8 *)da, dlb, 2 * xsize,
			    ysize, lut);
			break;

		case 3:
			mlib_c_ImageScalarBlend_U8_3((mlib_u8 *)sa1, slb1,
			    (mlib_u8 *)sa2, slb2, (mlib_u8 *)da, dlb, 3 * xsize,
			    ysize, lut);
			break;

		case 4:
			mlib_c_ImageScalarBlend_U8_124((mlib_u8 *)sa1, slb1,
			    (mlib_u8 *)sa2, slb2, (mlib_u8 *)da, dlb, 4 * xsize,
			    ysize, lut);
			break;

		default:
			return (MLIB_FAILURE);
		}

		return (MLIB_SUCCESS);
	} else if (dtype == MLIB_SHORT) {