|
| 1 | +# imcomplement |
| 2 | + |
| 3 | +```julia |
| 4 | +J = imcomplement(I::GMTimage) -> GMTimage |
| 5 | +``` |
| 6 | + |
| 7 | +*keywords: GMT, Julia, image processing* |
| 8 | + |
| 9 | +Compute the complement of the image `I` and returns the result in `J`. |
| 10 | + |
| 11 | +`I` can be a binary, intensity, or truecolor image. `J` has the same type and size as `I`. `I` can |
| 12 | +also be just a matrix. All types numeric (but complex) are allowed. |
| 13 | + |
| 14 | +In the complement of a binary image, black becomes white and white becomes black. In the case of a |
| 15 | +grayscale or truecolor image, dark areas become lighter and light areas become darker. |
| 16 | + |
| 17 | +The ``imcomplement!`` function works in-place and returns the modified ``I``. |
| 18 | + |
| 19 | +### Returns |
| 20 | +- A new \myreflink{GMTimage} |
| 21 | + |
| 22 | +Example |
| 23 | +------- |
| 24 | + |
| 25 | +Reverse Black and White in a Binary Image. |
| 26 | + |
| 27 | +\begin{examplefig}{} |
| 28 | +```julia |
| 29 | +using GMT |
| 30 | + |
| 31 | +text(["Hello World"], region=(1.92,2.08,1.97,2.02), x=2.0, y=2.0, |
| 32 | + font=(30, "Helvetica-Bold", :white), |
| 33 | + frame=(axes=:none, bg=:black), figsize=(6,0), name="tmp.png") |
| 34 | + |
| 35 | +# Read only one band (althouh gray scale, the "tmp.png" is actually RGB) |
| 36 | +I = gmtread("tmp.png", band=1); |
| 37 | +Ic = imcomplement(I); |
| 38 | + |
| 39 | +# Show the two |
| 40 | +grdimage(I, figsize=8) |
| 41 | +grdimage!(Ic, figsize=8, yshift=-2.57, show=true) |
| 42 | +``` |
| 43 | +\end{examplefig} |
| 44 | + |
| 45 | +Create the Complement of a Color Image |
| 46 | + |
| 47 | +\begin{examplefig}{} |
| 48 | +```julia |
| 49 | +using GMT |
| 50 | + |
| 51 | +I = gmtread(GMT.TESTSDIR * "assets/table_flowers.jpg"); |
| 52 | +Ic = imcomplement(I); |
| 53 | + |
| 54 | +grdimage(I, figsize=6) |
| 55 | +grdimage!(Ic, figsize=6, xshift=6, show=true) |
| 56 | +``` |
| 57 | +\end{examplefig} |
| 58 | + |
| 59 | +See Also |
| 60 | +-------- |
| 61 | + |
| 62 | +\myreflink{binarize} |
0 commit comments