Exemplo n.º 1
1
 public function render()
 {
     //Example ImagickKernel::getMatrix
     $output = "The built-in kernel name 'ring' with parameters of '2,3.5':<br/>";
     $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_RING, "2,3.5");
     $matrix = $kernel->getMatrix();
     $output .= Display::renderKernelTable($matrix);
     $output .= "Or as an image: " . $this->renderCustomImageURL();
     return $output;
     //Example end
 }
Exemplo n.º 2
1
 public function render()
 {
     switch ($this->fromMatrixControl->getKernelRender()) {
         case KernelRender::KERNEL_RENDER_IMAGE:
             return $this->renderImageURL();
             break;
         case KernelRender::KERNEL_RENDER_VALUES:
             $kernel = createFromMatrix();
             return Display::renderKernelTable($kernel->getMatrix());
     }
     return $this->renderImageURL();
 }
Exemplo n.º 3
1
 public function render()
 {
     switch ($this->builtInControl->getKernelRender()) {
         case KernelRender::KERNEL_RENDER_IMAGE:
             return $this->renderImageURL();
             break;
         case KernelRender::KERNEL_RENDER_VALUES:
             $kernel = createFromBuiltin($this->builtInControl->getKernelType(), $this->builtInControl->getKernelFirstTerm(), $this->builtInControl->getKernelSecondTerm(), $this->builtInControl->getKernelThirdTerm());
             return Display::renderKernelTable($kernel->getMatrix());
     }
     return "Unknown render type.";
 }
Exemplo n.º 4
0
 /**
  * @return string
  */
 public function render()
 {
     //Example Imagick::identifyFormat
     $output = "Output of 'Trim box: %@ number of unique colors: %k' is: <br/>";
     $imagick = new \Imagick(realpath("./images/artifact/mask.png"));
     $output .= $imagick->identifyFormat("Trim box: %@ number of unique colors: %k");
     //Example end
     $output .= "<br/>";
     $output .= "For this image:<br/>";
     $output .= Display::renderImgTag('/images/artifact/mask.png');
     return $output;
 }
Exemplo n.º 5
0
 public function render()
 {
     //Example ImagickKernel::addUnityKernel
     $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]];
     $kernel = \ImagickKernel::fromMatrix($matrix);
     $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE);
     $output = "Before adding unity kernel: <br/>";
     $output .= Display::renderKernelTable($kernel->getMatrix());
     $kernel->addUnityKernel(0.5);
     $output .= "After adding unity kernel: <br/>";
     $output .= Display::renderKernelTable($kernel->getMatrix());
     $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE);
     $output .= "After renormalizing kernel: <br/>";
     $output .= Display::renderKernelTable($kernel->getMatrix());
     return $output;
     //Example end
 }
Exemplo n.º 6
0
 public function render()
 {
     //Example ImagickKernel::separate
     $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]];
     $kernel = \ImagickKernel::fromMatrix($matrix);
     $kernel->scale(4, \Imagick::NORMALIZE_KERNEL_VALUE);
     $diamondKernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_DIAMOND, "2");
     $kernel->addKernel($diamondKernel);
     $kernelList = $kernel->separate();
     $output = '';
     $count = 0;
     foreach ($kernelList as $kernel) {
         $output .= "<br/>Kernel {$count}<br/>";
         $output .= Display::renderKernelTable($kernel->getMatrix());
         $count++;
     }
     return $output;
     //Example end
 }
Exemplo n.º 7
0
 public function render()
 {
     //Example ImagickKernel::scale
     $output = "";
     $matrix = [[-1, 0, -1], [0, 4, 0], [-1, 0, -1]];
     $kernel = \ImagickKernel::fromMatrix($matrix);
     $kernelClone = clone $kernel;
     $output .= "Start kernel<br/>";
     $output .= Display::renderKernelTable($kernel->getMatrix());
     $output .= "Scaling with NORMALIZE_KERNEL_VALUE. The  <br/>";
     $kernel->scale(2, \Imagick::NORMALIZE_KERNEL_VALUE);
     $output .= Display::renderKernelTable($kernel->getMatrix());
     $kernel = clone $kernelClone;
     $output .= "Scaling by percent<br/>";
     $kernel->scale(2, \Imagick::NORMALIZE_KERNEL_PERCENT);
     $output .= Display::renderKernelTable($kernel->getMatrix());
     $matrix2 = [[-1, -1, 1], [-1, false, 1], [1, 1, 1]];
     $kernel = \ImagickKernel::fromMatrix($matrix2);
     $output .= "Scaling by correlate<br/>";
     $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_CORRELATE);
     $output .= Display::renderKernelTable($kernel->getMatrix());
     return $output;
     //Example end
 }
Exemplo n.º 8
0
 public function renderDescription()
 {
     $output = "Applies a morpholohy effect to an image using an ImagickKernel. Please see the <a href='http://www.imagemagick.org/Usage/morphology/'>ImageMagick page on Morpgology</a> for exact details. <br/>&nbsp;<br/>";
     if (array_key_exists($this->morphologyType, $this->functionTable) == false) {
         $output .= "Example not done yet.";
     }
     switch ($this->morphologyType) {
         case \Imagick::MORPHOLOGY_CONVOLVE:
             $output .= "Applies the kernel to the image with as a convolve (aka multiplication) function.";
             break;
         case \Imagick::MORPHOLOGY_CORRELATE:
             $correlateTable = Display::renderKernelTable(self::$correlateMatrix);
             $output .= "Applies the kernel to the image with as a correlation (aka pattern matching) function. The kernel <br/>&nbsp;<br/>" . $correlateTable . " <br/> finds the top left edges in an image. The value '1' means the pixel there must be white, '-1' means the pixel must be black and false means we do not care what color that pixel has.";
             break;
         case \Imagick::MORPHOLOGY_ERODE:
             $output .= "Erode the edges of an image.";
             break;
         case \Imagick::MORPHOLOGY_DILATE:
             $output .= "Dilate (expand) the edges of an image.";
             break;
         case \Imagick::MORPHOLOGY_ERODE_INTENSITY:
             $output .= "Erode the edges of a color image.";
             break;
         case \Imagick::MORPHOLOGY_DILATE_INTENSITY:
             $output .= "Dilate (expand) the edges of a color image.";
             break;
         case \Imagick::MORPHOLOGY_DISTANCE . "Chebyshev":
             $output .= "Measure the distance from the edge using the Chebyshev kernel.";
             break;
         case \Imagick::MORPHOLOGY_DISTANCE . "Manhattan":
             $output .= "Measure the distance from the edge using the Manhattan kernel.";
             break;
         case \Imagick::MORPHOLOGY_DISTANCE . "Octagonal":
             $output .= "Measure the distance from the edge using the Octagonal kernel.";
             break;
         case \Imagick::MORPHOLOGY_DISTANCE . "Euclidian":
             $output .= "Measure the distance from the edge using the Euclidian kernel.";
             break;
         case \Imagick::MORPHOLOGY_ITERATIVE:
             break;
         case \Imagick::MORPHOLOGY_OPEN:
             $output .= "Open smooths the outline, by rounding off any sharp points, and removing any parts that is smaller than the shape used. It will also disconnect or 'open' any thin bridges.";
             break;
         case \Imagick::MORPHOLOGY_CLOSE:
             $output .= "The basic effect of this operator is to smooth the outline of the shape, by filling in (closing) any holes, and indentations. It also will form connecting 'bridges' to other shapes that are close enough for the kernel to touch both simultaneously. But it does not make the basic 'core' size of the shape larger or smaller.";
             break;
         case \Imagick::MORPHOLOGY_OPEN_INTENSITY:
             $output .= "Open smooths the outline, but for a color image.";
             break;
         case \Imagick::MORPHOLOGY_CLOSE_INTENSITY:
             $output .= "Open closes the outline, but for a color image.";
             break;
         case \Imagick::MORPHOLOGY_SMOOTH:
             $output .= "Smooths the edge of an image.";
             break;
         case \Imagick::MORPHOLOGY_EDGE_IN:
             $output .= "Find the inside edge of an image.";
             break;
         case \Imagick::MORPHOLOGY_EDGE_OUT:
             $output .= "Find the outside edge of an image.";
             break;
         case \Imagick::MORPHOLOGY_EDGE:
             $output .= "Find the edge of an image. This is the sum of the 'edge in' and 'edge out'.";
             break;
         case \Imagick::MORPHOLOGY_TOP_HAT:
             $output .= "The 'TopHat' method, or more specifically 'White Top Hat', returns the pixels that were removed by a Opening of the shape, that is the pixels that were removed to round off the points, and the connecting bridged between shapes.";
             break;
         case \Imagick::MORPHOLOGY_BOTTOM_HAT:
             $output .= "The 'BottomHat' method, also known as 'Black TopHat' is the pixels that a Closing of the shape adds to the image. That is the the pixels that were used to fill in the 'holes', 'gaps', and 'bridges'.";
             break;
         case \Imagick::MORPHOLOGY_HIT_AND_MISS:
             $output .= "The 'Hit-And-Miss' morphology method, also commonly known as 'HMT' in computer science literature, is a high level morphology method that is specifically designed to find and locate specific patterns in images. It does this by looking for a specific configuration of 'foreground' and 'background' pixels around the 'origin'.";
             break;
         case \Imagick::MORPHOLOGY_THINNING:
             $output .= "The 'Thinning' method is the dual of 'Thicken'. Rather than adding pixels, this method subtracts them from the original image.";
             break;
         case \Imagick::MORPHOLOGY_THICKEN . "Standard":
             $output .= "The 'Thicken' method will add pixels to the original shape at every matching location.";
             break;
         case \Imagick::MORPHOLOGY_THICKEN . "Convex":
             $output .= "The actual 'ConvexHull' kernel is really designed to work with image shapes, and will expand a shape into a 'Octagonal Convex Hull'. That is it will try to fill in all the gaps between the extremes until it produces a 'octagonal shaped' object.";
             break;
     }
     return $output;
 }