-
Notifications
You must be signed in to change notification settings - Fork 80
/
MagickImage.java
1799 lines (1618 loc) · 61.1 KB
/
MagickImage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package magick;
import java.awt.Dimension;
import java.awt.Rectangle;
/**
* Encapsulation of the ImageMagick Image object.
* We use MagickImage here so as not to be confused
* with java.awt.Image.
*
* @author Eric Yeo
*/
public class MagickImage extends Magick {
/**
* Internal ImageMagick Image handle.
* We use long (64-bits) for portability.
*/
private long magickImageHandle = 0;
/**
* Constructor.
*/
public MagickImage()
{
}
/**
* Construct a MagickImage that is made up of all
* the images in the specified array. If any of
* the images contains multiple frames, the frames
* are also appended to the new image. All the
* images are cloned.
* @param images array of images to linked
*/
public MagickImage(MagickImage[] images)
throws MagickException
{
initMultiImage(images);
}
/**
* Helper for the constcutor to create an image that
* is made up of all the images in the specified array.
* If any of the images contains multiple frames, the
* frames are also appended to the new image. All the
* images are cloned.
* @param images array of images to linked
* @throws MagickException if the new image cannot be constructed
* @see MagickImage
*/
private native void initMultiImage(MagickImage[] images)
throws MagickException;
/**
* Constructor that also reads an image file
* specified in the parameter.
*
* @param imageInfo the ImageInfo for an image file to read
* @param boolean true for ping the image only.
*
* @exception MagickException on error
*/
public MagickImage(ImageInfo imageInfo, boolean ping)
throws MagickException
{
if (ping) {
pingImage(imageInfo);
}
else {
readImage(imageInfo);
}
}
/**
* Pings the image.
* @param imageInfo the ImageInfo for an image file to read
* @see <a href="http://www.imagemagick.org/api/constitute.php#PingImage">The underlying ImageMagick call</a>
*/
public native void pingImage(ImageInfo imageInfo)
throws MagickException;
/**
* Constructor that also reads an image file
* specified in the parameter.
*
* @param imageInfo the ImageInfo for an image file to read
*
* @exception MagickException on error on error
*/
public MagickImage(ImageInfo imageInfo)
throws MagickException
{
readImage(imageInfo);
}
/**
* Constructor that takes the image to be read from memory.
*
* @param imageInfo the ImageInfo instance for default settings, etc
* @param blob the image to be read in memory
*
* @exception MagickException on error
*/
public MagickImage(ImageInfo imageInfo, byte[] blob)
throws MagickException
{
blobToImage(imageInfo, blob);
}
/**
* This method will clean up the handle.
*/
protected void finalize()
{
destroyImages();
}
/**
* Allocate a blank image object.
*
* @param imageInfo specifies the parameters for the blank image
*/
public native void allocateImage(ImageInfo imageInfo);
/**
* Read the image specified in the ImageInfo object.
*
* @param imageInfo specifies the file to read from
* @see <a href="http://www.imagemagick.org/api/constitute.php#ReadImage">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native void readImage(ImageInfo imageInfo)
throws MagickException;
/**
* Write the image specified in the ImageInfo object.
*
* @param imageInfo specifies the writing parameters
*
* @exception MagickException on error
*/
public native boolean writeImage(ImageInfo imageInfo)
throws MagickException;
/**
* Return the image file name of the image.
*
* @return the file name of the image
* @exception MagickException on error
*/
public native String getFileName()
throws MagickException;
/**
* Set the image file name.
*
* @param fileName new file name
*
* @exception MagickException on error
*/
public native void setFileName(String fileName)
throws MagickException;
/**
* Set the filter type.
*
* @param filter the filter type from constants defined in the class FilterType
* @see FilterType
* @exception MagickException on error
*/
public native void setFilter(int filter)
throws MagickException;
/**
* Get the filter type.
*
* @return the filter type as defined in the class FilterType
* @see FilterType
* @exception MagickException on error
*/
public native int getFilter()
throws MagickException;
/**
* Adds random noise to the image.
*
* @param noiseType The type of noise: Uniform, Gaussian, Multiplicative,
* Impulse, Laplacian, or Poisson.
* @see NoiseType
* @return An image with additional noise.
* @see <a href="http://www.imagemagick.org/api/effect.php#AddNoiseImage">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native MagickImage addNoiseImage(int noiseType)
throws MagickException;
/**
* Return the number of columns and rows of the image.
* @return the dimension of the image
* @exception MagickException on error
*/
public native Dimension getDimension()
throws MagickException;
/**
* Return the depth of the image.
*
* @return the depth of the image.
* @exception MagickException on error
*/
public native int getDepth()
throws MagickException;
/**
* Set the depth of the image.
*
* @param depth the depth of the image
* @exception MagickException on error
*/
public native void setDepth(int depth)
throws MagickException;
/**
* Blurs an image. We convolve the image with a Gaussian operator of
* the given radius and standard deviation (sigma). For reasonable
* results, the radius should be larger than sigma. Use a radius of 0
* and BlurImage() selects a suitable radius for you.
*
* @param raduis The radius of the gaussian, in pixels, not counting
* the center pixel
* @param sigma The standard deviation of the gaussian, in pixels
*
* @return A blurred image.
* @exception MagickException on error
*/
public native MagickImage blurImage(double raduis, double sigma)
throws MagickException;
/**
* Blurs an image. We convolve the image with a Gaussian operator of
* the given radius and standard deviation (sigma). For reasonable
* results, the radius should be larger than sigma. Use a radius of 0
* and BlurImage() selects a suitable radius for you.
*
* @param channel The channel(s) to which the blurring should apply
(see ChannelType)
* @param raduis The radius of the gaussian, in pixels, not counting
* the center pixel
* @param sigma The standard deviation of the gaussian, in pixels
*
* @return A blurred image.
* @exception MagickException on error
*/
public native MagickImage blurImageChannel(int channel, double raduis, double sigma)
throws MagickException;
/**
* Trim edges that are the background color from the image.
* @exception MagickException on error
*/
public native MagickImage trimImage()
throws MagickException;
/**
* resets the image page canvas and position..
* @param page String representing the new page geometry
* @return Who knows?
*/
public native boolean resetImagePage(String page)
throws MagickException;
/**
* Return the storage class of the image.
*
* @return the store class as defined in ClassType
* @see ClassType
* @exception MagickException on error
*/
public native int getStorageClass()
throws MagickException;
/*
* Annotates an image with test. Optionally the annotation can
* include the image filename, type, width, height, or scene
* number by embedding special format characters.
*
* @param info the anotation information
*/
public native void annotateImage(DrawInfo info);
/**
* Surrounds the image with a border of the color defined by
* the border color member of the image structure. The width
* and height of the border are defined by the corresponding
* members of the Rectangle.
*
* @param borderInfo the rectangle for which border is drawn
* @return an Image with a border around it
* @exception MagickException on error
* @see #setBorderColor
* @see #getBorderColor
*/
public native MagickImage borderImage(Rectangle borderInfo)
throws MagickException;
/**
* Creates a new image that is a copy of an existing one with the
* edges highlighted, producing a 'charcoal-drawing' effect.
*
* @param raduis The radius of the pixel neighborhood.
* @param sigma The standard deviation of the gaussian, in pixels
*
* @return A charcoal-like image.
* @exception MagickException on error
*/
public native MagickImage charcoalImage(double raduis, double sigma)
throws MagickException;
/**
* Creates a simulated three-dimensional button-like effect by
* lightening and darkening the edges of the image. Members width
* and height of raiseInfo define the width of the vertical and
* horizontal edge of the effect.
*
* @param raiseInfo the rectangle for which border is drawn
* @param raise true to create raise effect, false to lower
* @return true if successful, false otherwise
* @exception MagickException on error
*/
public native boolean raiseImage(Rectangle raiseInfo, boolean raise)
throws MagickException;
/**
* Creates a new image that is a subregion of the original.
*
* @param chopInfo the rectange to chop the image
* @exception MagickException on error
*/
public native MagickImage chopImage(Rectangle chopInfo)
throws MagickException;
/**
* Colourises the image with a pen colour.
*
* @param opacity string percentage value for opacity
* @param target a colour value
* @exception MagickException on error
*/
public native MagickImage
colorizeImage(String opacity, PixelPacket target)
throws MagickException;
/**
* Composite the image supplied onto itself at the specified offsets.
* @see <a href="http://www.imagemagick.org/script/command-line-options.php#compose">Command line explanation</a>
* @see <a href="http://www.imagemagick.org/api/composite.php">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native boolean compositeImage(int compOp,
MagickImage compImage,
int xOff,
int yOff)
throws MagickException;
/**
* Composites a set of images while respecting any page offsets and disposal methods.
* @see <a href="http://www.imagemagick.org/api/layer.php#CoalesceImages">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native MagickImage coalesceImages()
throws MagickException;
/**
* Returns the coalesced frames of a GIF animation as it would appear after the GIF dispose method of that frame has been applied..
* @see <a href="http://www.imagemagick.org/api/layer.php#DisposeImages">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native MagickImage disposeImages()
throws MagickException;
/**
* Enhances the intensity differences between the lighter and
* darker elements of the image.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean contrastImage(boolean sharpen)
throws MagickException;
/**
* Returns a copy of all fields of the input image.
* The the pixel memory is allocated but the pixel data is copy
* is optional.
* @return a cloned image
* @exception MagickException on error
*/
public native MagickImage cloneImage(int columns, int rows,
boolean clonePixels)
throws MagickException;
/**
* Create a new image of 8-bit component of the specified dimensions.
*
* @param width the width of the new image
* @param height the height of the new image
* @param map the components of a pixel
* @param pixels the raw image in an array of pixels
* @see <a href="http://www.imagemagick.org/api/constitute.php#ConstituteImage">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native void constituteImage(int width, int height,
String map, byte[] pixels)
throws MagickException;
/**
* Create a new image of 32-bit component of the specified dimensions.
*
* @param width the width of the new image
* @param height the height of the new image
* @param map the components of a pixel
* @param pixels the raw image in an array of pixels
* @see <a href="http://www.imagemagick.org/api/constitute.php#ConstituteImage">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native void constituteImage(int width, int height,
String map, int[] pixels)
throws MagickException;
/**
* Create a new image of float component of the specified dimensions.
*
* @param width the width of the new image
* @param height the height of the new image
* @param map the components of a pixel
* @param pixels the raw image in an array of pixels
* @see <a href="http://www.imagemagick.org/api/constitute.php#ConstituteImage">The underlying ImageMagick call</a>
* @exception MagickException on error
*/
public native void constituteImage(int width, int height,
String map, float[] pixels)
throws MagickException;
/**
* Creates a new image that is a subregion of the original.
*
* @param chopInfo the subimage
* @return a subimage of the original
* @exception MagickException on error
*/
public native MagickImage cropImage(Rectangle chopInfo)
throws MagickException;
/**
* Cycles the image colormap by a specified amount.
* @exception MagickException on error
*/
public native void cycleColormapImage(int amount)
throws MagickException;
/**
* Called by finalize to deallocate the image handle.
*/
public native void destroyImages();
/**
* Draws a primitive (line, rectangle, ellipse) on the image.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean drawImage(DrawInfo aInfo)
throws MagickException;
/**
* Finds edges in an image. Radius defines the radius of the convolution
* filter. Use a radius of 0 and Edge() selects a suitable radius for you.
*
* @param raduis The radius of the pixel neighborhood.
*
* @return A new image with the edges hilighted.
* @exception MagickException on error
*/
public native MagickImage edgeImage(double raduis)
throws MagickException;
/**
* Returns a grayscale image with a three-dimensional effect.
* We convolve the image with a Gaussian operator of the given radius
* and standard deviation (sigma). For reasonable results, radius
* should be larger than sigma. Use a radius of 0 and Emboss() selects
* a suitable radius for you.
*
* @param raduis The radius of the pixel neighborhood.
* @param sigma The standard deviation of the Gaussian, in pixels
*
* @return A new, embossed, image.
* @exception MagickException on error
*/
public native MagickImage embossImage(double raduis, double sigma)
throws MagickException;
/**
* Applies a digital filter that improves the quality of a noisy image.
*
* @return A new, enhanced, image.
* @exception MagickException on error
*/
public native MagickImage enhanceImage()
throws MagickException;
/**
* Performs histogram equalization.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean equalizeImage()
throws MagickException;
/**
* Creates a new image that reflects each scanline
* in the vertical direction.
* @return a new image that has been flipped
* @exception MagickException on error
*/
public native MagickImage flipImage()
throws MagickException;
/**
* Creates a new image that reflects each scanline in the
* horizontal direction
* @return a new image that has been flopped
* @exception MagickException on error
*/
public native MagickImage flopImage()
throws MagickException;
/**
* Converts the reference image to gamma corrected colors.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean gammaImage(String gamma)
throws MagickException;
/**
* Blurs the image using a gaussian operator. The effectiveness of the
* operator - and the amount of blurring - is controlled by selecting
* a 'radius' and a 'sigma'. The radius sets the circle around each
* pixel of the 'neighborhood' used for calculating an average pixel
* color. Sigma determines how much the calculated average affects the
* pixel.
*
* @param raduis The radius of the Gaussian, in pixels, not counting
* the center pixel
* @param sigma The standard deviation of the Gaussian, in pixels.
*
* @return A new, blurred, image.
* @exception MagickException on error
*/
public native MagickImage gaussianBlurImage(double raduis, double sigma)
throws MagickException;
/**
* Implodes the image's pixels about the center.
*
* @param amount Amount of implosion if positive, explosion if negative.
*
* @return A new, imploded, image.
* @exception MagickException on error
*/
public native MagickImage implodeImage(double amount)
throws MagickException;
/**
* Returns True if the image is grayscale otherwise False is returned.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean isGrayImage()
throws MagickException;
/**
* Returns True if the image is monochrome otherwise False is returned.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean isMonochromeImage()
throws MagickException;
/**
* Creates a new image that is a integral size greater
* than an existing one.
*
* @return a magnified image
* @exception MagickException on error
*/
public native MagickImage magnifyImage()
throws MagickException;
/**
* Floodfills the designated area with a matte value.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean matteFloodfillImage(PixelPacket target,
int matte,
int x,
int y,
int method)
throws MagickException;
/**
* Changes the color value of any pixel that matches target
* and is an immediate neighbor. If the method FillToBorderMethod
* is specified, the color value is changed for any neighbor pixel
* that does not match the bordercolor member of image.
*
* By default target must match a particular pixel color exactly.
* However, in many cases two colors may differ by a small amount.
* The fuzz member of image defines how much tolerance is acceptable to
* consider two colors as the same. For example, set fuzz to 10 and the
* color red at intensities of 100 and 102 respectively are now
* interpreted as the same color for the purposes of the floodfill.
*
* @param drawInfo The draw info
* @param target The RGB value of the target colour
* @param x the starting x location of the operation
* @param y the starting y location of the operation
* @param method either FloodfillMethod or FilltoBorderMethod
* @return true or false depending on success or failure respectively
* @throws MagickException if any error occurs
* @see magick.PaintMethod
*/
public native boolean colorFloodfillImage(DrawInfo drawInfo,
PixelPacket target,
int x,
int y,
int method)
throws MagickException;
/**
* Applies a digital filter that improves the quality of a noisy image.
* Each pixel is replaced by the median in a set of neighboring pixels
* as defined by radius.
*
* @param radius The radius of the pixel neighborhood.
*
* @return A new, filtered, image.
* @exception MagickException on error
*/
public native MagickImage medianFilterImage(double radius)
throws MagickException;
/**
* Creates a new image that is a integral size less than an existing one.
* @return a minified image
* @exception MagickException on error
*/
public native MagickImage minifyImage()
throws MagickException;
/**
* Modulates the hue, saturation, and brightness of an image.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean modulateImage(String modulate)
throws MagickException;
/**
* Negates the colors in the reference image. The Grayscale
* option means that only grayscale values within the image are negated.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean negateImage(int grayscale)
throws MagickException;
/**
* Normalizes the pixel values to span the full range of color values.
* This is a contrast enhancement technique.
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean normalizeImage()
throws MagickException;
/**
* Applies a special effect filter that simulates an oil painting.
* Each pixel is replaced by the most frequent color occurring in a
* circular region defined by radius.
*
* @param radius The radius of the pixel neighborhood.
*
* @return A new, simulated oil-painting, image.
* @exception MagickException on error
*/
public native MagickImage oilPaintImage(double radius)
throws MagickException;
/**
* Changes the color of an opaque pixel to the pen color.
* @param target the color to search for in the image
* @param penColor the color to replace it with
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean opaqueImage(PixelPacket target, PixelPacket penColor)
throws MagickException;
/**
* This operation attempts to reduce the 'noise' in the image. This
* can be used to eliminate minor dust and scratches from scanned
* images.
*<p>
* The principal function of the noise peak elimination filter is to
* smooth the objects within an image without losing edge information
* and without creating undesired structures. The central idea of the
* algorithm is to replace a pixel with its next neighbor in value in
* a circular neighborhood if this pixel has been found to be noise. A
* pixel is defined as noise if the pixel is a minimum or maximum
* within the neighborhood.
*
* @param radius The radius of the pixel neighborhood.
*
* @return A new, filtered, image.
* @exception MagickException on error
*/
public native MagickImage reduceNoiseImage(double radius)
throws MagickException;
/**
* Converts the reference image from RGB to an alternate colorspace.
* The transformation matrices are not the standard ones: the weights
* are rescaled to normalized the range of the transformed values to
* be [0..MaxRGB].
* @param colorspace the target colorspace to transform to
* @return a boolean value to indicate success
* @exception MagickException on error
*/
public native boolean rgbTransformImage(int colorspace)
throws MagickException;
/**
* Rolls an image vertically and horizontally.
* @param xOffset An integer that specifies the number of columns \
to roll in the horizontal direction
* @param yOffset An integer that specifies the number of rows to \
roll in the vertical direction
* @return the rolled image
* @exception MagickException on error
*/
public native MagickImage rollImage(int xOffset, int yOffset)
throws MagickException;
/**
* Creates a new image that is a scaled size of an existing one
* using pixel sampling.
* @param cols An integer that specifies the number of columns in \
the sampled image
* @param rows An integer that specifies the number of rows in the \
sampled image
* @return the sampled image
* @exception MagickException on error
*/
public native MagickImage sampleImage(int cols, int rows)
throws MagickException;
/**
* Return a new image that is a scaled version of the
* original. To scale a scanline from x pixels to y pixels, each new
* pixel represents x/y old pixels. To read x/y pixels, read
* (x/y rounded up) pixels but only count the required fraction of
* the last old pixel read in your new pixel. The remainder of the
* old pixel will be counted in the next new pixel.
* @param cols An integer that specifies the number of columns in \
the scaled image
* @param rows An integer that specifies the number of rows in the \
scaled image
* @return the scaled image
* @exception MagickException on error
*/
public native MagickImage scaleImage(int cols, int rows)
throws MagickException;
/**
* Return a new image that is a resized version of the original.
* If an undefined filter is given the filter defaults to Mitchell for a
* colormapped image, a image with a matte channel, or if the image is
* enlarged. Otherwise the filter defaults to a Lanczos.
*
* @param cols An integer that specifies the number of columns in
* the resized image
* @param rows An integer that specifies the number of rows in the
* resized image
* @param blur - The blur factor where > 1 is blurry, < 1 is sharp.
* Typically set this to 1.0.
* @return the resized image
* @exception MagickException on error
* @author Pavel Cibulka
*/
public native MagickImage resizeImage(int cols, int rows, double blur)
throws MagickException;
/**
* Segment an image by analyzing the histograms of the color components
* and identifying units that are homogeneous using the fuzzy c-means
* technique.
*
* @param colorspace A {@link ColorspaceType} value that indicates the
* colorspace. Empirical evidence suggests that
* distances in YUV or YIQ correspond to perceptual
* color differences more closely than do distances
* in RGB space. The image is then returned to RGB
* colorspace after color reduction.
* @param cluster_threshold Specify cluster threshold as the number of
* pixels in each cluster must exceed the the
* cluster threshold to be considered valid.
* @param smoothing_threshold Smoothing threshold eliminates noise in
* the second derivative of the histogram. As the
* value is increased, you can expect a smoother
* second derivative. The default is 1.5.
*
* @return The actual number of colors allocated in the colormap.
* @exception MagickException on error
* @see ColorspaceType
*/
public native int segmentImage(int colorspace, double cluster_threshold,
double smoothing_threshold)
throws MagickException;
/**
* Applies a special effect to the image, similar to the effect achieved
* in a photo darkroom by selectively exposing areas of photo sensitive
* paper to light.
*
* @param threshold Ranges from 0 to MaxRGB and is a measure of the
* extent of the solarization.
*
* @exception MagickException on error
*/
public native void solarizeImage(double threshold)
throws MagickException;
/**
* Sorts the colormap of a PseudoClass image by decreasing
* color intensity.
* @return a boolean value indicating success
* @exception MagickException on error
*/
public native boolean sortColormapByIntensity()
throws MagickException;
/**
* A special effects method that randomly displaces each pixel in a
* block defined by the radius parameter.
*
* @param radius Choose a random pixel in a neighborhood of this extent.
*
* @return A new, spread, image.
* @exception MagickException on error
*/
public native MagickImage spreadImage(int radius)
throws MagickException;
/**
* Swirls the pixels about the center of the image, where degrees
* indicates the sweep of the arc through which each pixel is moved.
* You get a more dramatic effect as the degrees move from 1 to 360.
*
* @param degrees Defines the tightness of the swirling effect.
*
* @return A new, swirled, image.
* @exception MagickException on error
*/
public native MagickImage swirlImage(double degress)
throws MagickException;
/**
* Initializes the red, green, and blue intensities of each
* pixel as defined by the colormap index.
* @exception MagickException on error
*/
public native void syncImage()
throws MagickException;
/**
* Layers a texture onto the background of an image.
* @param image the image to use for texture
* @exception MagickException on error
*/
public native void textureImage(MagickImage image)
throws MagickException;
/**
* Thresholds the reference image.
* @param threshold the threshold value
* @return a boolean value indicating success
* @exception MagickException on error
*/
public native boolean thresholdImage(double threshold)
throws MagickException;
/**
* Creates a new image that is a transformed size of of
* existing one as specified by the crop and image geometries.
*
* If a crop geometry is specified a subregion of the image is
* obtained. If the specified image size, as defined by the image
* and scale geometries, is smaller than the actual image size, the
* image is first minified to an integral of the specified image
* size with an antialias digital filter. The image is then scaled to
* the exact specified image size with pixel replication. If the
* specified image size is greater than the actual image size, the
* image is first enlarged to an integral of the specified image size
* with bilinear interpolation. The image is then scaled to the exact
* specified image size with pixel replication.
*
* @param cropGeometry a crop geometry string. This geometry \
defines a subregion of the image.
* @param imageGeometry a image geometry string. The specified \
width and height of this geometry string
are absolute.
* @exception MagickException on error
*/
public native void transformImage(String cropGeometry,
String imageGeometry)
throws MagickException;
/**
* Converts the reference image from an alternate colorspace.
* The transformation matrices are not the standard ones:
* the weights are rescaled to normalized the range of the
* transformed values to be [0..MaxRGB].
*
* @param colorspace An unsigned integer value defines which \
colorspace to transform the image to
* @return a boolean value indicating success
* @exception MagickException on error
*/
public native boolean transformRgbImage(int colorspace)
throws MagickException;
/**
* Creates a matte image associated with the image.
* @param color The color to search for in the image
* @param opacity The opacity of the transparent image
* @return a boolean value indicating success
* @exception MagickException on error
*/
public native boolean transparentImage(PixelPacket color, int opacity)
throws MagickException;
/**
* Create a Nx1 pixel image where N is the number of unique colors in
* the image. Each pixel in the output image is the color of one of
* the unique colors of the original image.
**/
public native MagickImage uniqueImageColors()
throws MagickException;
/**
* Creates a new image that is a copy of an existing one with
* the pixels sharpened using an "unsharp" masking technique.
*<p>
* This process starts by building a temporary, {@link
* #gaussianBlurImage blurred}, copy of the image. Then each
* pixel in this "unsharp" image is compared
* against its corresponding pixel in the original image. If
* their difference is above a threshold, a percentage of the
* difference is added back into the original pixel.
*<p>
* The first two arguments, <tt>radius</tt> and <tt>sigma</tt>,
* specify the blurring used to create the "unsharp" image. See
* {@link #gaussianBlurImage} for a detail explanation. It will
* suffice to say that the larger the radius and sigma the more
* this blurred image will diverge from the original.
*<p>
* The last two arguments, <tt>threshold</tt> and <tt>amount</tt>,
* specify the difference threshold required to apply an adjustment
* to each pixel and, once the threshold is reached, the amount of
* the difference to be added back into the original pixels. A high
* threshold will cause the algorithm to only adjust edge pixels.
* Specifying a threshold will adjust every pixel.
*
* @param raduis The radius of the gaussian, in pixels, not counting
the center pixel
* @param sigma The standard deviation of the gaussian, in pixels
* @param amount The percentage of the difference between the original
* and the blur image that is added back into the original.
* @param threshold The threshold in pixels needed to apply the diffence
* amount.
*
* @return A sharpened image.
*
* @exception MagickException on error