示例#1
0
/**
 *   Type are:
 *   - Uniform 0
 *   - Gaussian 1
 *   - Multiplicative 2
 *   - Impulse 3
 *   - Laplacian 4
 *   - Poisson 5
 */
Handle<Value> MerlinImage::AddNoiseImage(const Arguments& args) {
    HandleScope scope;
    MagickWand* wand = MerlinImage::ReadImage(  ObjectWrap::Unwrap<MerlinImage>(args.This()) );

    const int type = args[0]->IntegerValue();
    NoiseType t;
    switch(type) {
    case 0:
        t = UniformNoise;
        break;
    case 1:
        t = GaussianNoise;
        break;
    case 2:
        t = MultiplicativeGaussianNoise;
        break;
    case 3:
        t = ImpulseNoise;
        break;
    case 4:
        t = LaplacianNoise;
        break;
    case 5:
        t = PoissonNoise;
        break;
    }

    MagickAddNoiseImage(wand, t);

    return scope.Close(MerlinImage::WriteImage(wand));
}
示例#2
0
MagickBooleanType MagickAddNoiseImageChannel(MagickWand *wand,const ChannelType channel,const NoiseType noise_type) {
	MagickBooleanType status;
	ChannelType previous_channel_mask;

	if (channel != UndefinedChannel) {
		previous_channel_mask = MagickSetImageChannelMask(wand, channel);
	}

	//TODO - what is the value meant to be?
	status = MagickAddNoiseImage(wand, noise_type, 1.0);

	if (channel != UndefinedChannel) {
		(void) MagickSetImageChannelMask(wand, previous_channel_mask);
	}

	return status;
}