Skip to content

Instantly share code, notes, and snippets.

View tosinamuda's full-sized avatar

Tosin Amuda tosinamuda

View GitHub Profile
@tosinamuda
tosinamuda / image_center.php
Created December 14, 2017 12:47
How to center a text on an image using php gd
// Get image dimensions
$image_width = imagesx($image);
$image_height = imagesy($image);
$text_bound = imageftbbox($font_size, $angle, $font, $text);
//Get the text upper, lower, left and right corner bounds
$lower_left_x = $text_bound[0];
$lower_left_y = $text_bound[1];
$lower_right_x = $text_bound[2];
@tosinamuda
tosinamuda / EmguImageConversionUtilities.cs
Created March 27, 2019 09:57
Convert Image File to Matrix with EmguCV C# and Save Matrix as ImageFile
using OpenCV = Emgu.CV;
public class Utilities{
public static MathNet.Numerics.LinearAlgebra.Matrix<double>[] LoadImageMatrix(string path)
{
OpenCV.Mat mat = OpenCV.CvInvoke.Imread(path, OpenCV.CvEnum.ImreadModes.AnyColor);
OpenCV.Image<OpenCV.Structure.Bgr, double> image = mat.ToImage<OpenCV.Structure.Bgr, double>();
OpenCV.Image<OpenCV.Structure.Gray, double> blue = image[0];
OpenCV.Image<OpenCV.Structure.Gray, double> green = image[1];