Imagick::forwardFourierTransformImage

(PECL imagick 3 >= 3.3.0)

Imagick::forwardFourierTransformImageDescription

Description

public Imagick::forwardFourierTransformimage(bool $magnitude): bool

Implements the discrete Fourier transform (DFT) of the image either as a magnitude / phase or real / imaginary image pair.

Parameters

magnitude

If true, return as magnitude / phase pair otherwise a real / imaginary image pair.

Return Values

Returns true on success.

Examples

Example #1 Imagick::forwardFourierTransformImage()

<?php
//Utility function for forwardTransformImage
function createMask() {
    
$draw = new \ImagickDraw();

    
$draw->setStrokeOpacity(0);
    
$draw->setStrokeColor('rgb(255, 255, 255)');
    
$draw->setFillColor('rgb(255, 255, 255)');

    
//Draw a circle on the y-axis, with it's centre
    //at x, y that touches the origin
    
$draw->circle(250250220250);

    
$imagick = new \Imagick();
    
$imagick->newImage(512512"black");
    
$imagick->drawImage($draw);
    
$imagick->gaussianBlurImage(2020);
    
$imagick->autoLevelImage();

    return 
$imagick;
}


function 
forwardFourierTransformImage($imagePath) {
    
$imagick = new \Imagick(realpath($imagePath));
    
$imagick->resizeimage(512512, \Imagick::FILTER_LANCZOS1);

    
$mask createMask();
    
$imagick->forwardFourierTransformImage(true);

    @
$imagick->setimageindex(0);
    
$magnitude $imagick->getimage();

    @
$imagick->setimageindex(1);
    
$imagickPhase $imagick->getimage();

    if (
true) {
        
$imagickPhase->compositeImage($mask, \Imagick::COMPOSITE_MULTIPLY00);
    }

    if (
false) {
        
$output = clone $imagickPhase;
        
$output->setimageformat('png');
        
header("Content-Type: image/png");
        echo 
$output->getImageBlob();
    }

    
$magnitude->inverseFourierTransformImage($imagickPhasetrue);

    
$magnitude->setimageformat('png');
    
header("Content-Type: image/png");
    echo 
$magnitude->getImageBlob();
}

?>

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

PHP cURL Tutorial: Using cURL to Make HTTP Requests

cURL is a powerful PHP extension that allows you to communicate with different servers using various protocols, including HTTP, HTTPS, FTP, and more. ...

TheMax

Autor : TheMax
Category: PHP-Tutorials

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial