Recherche avancée

Médias (3)

Mot : - Tags -/spip

Autres articles (66)

  • La file d’attente de SPIPmotion

    28 novembre 2010, par

    Une file d’attente stockée dans la base de donnée
    Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
    Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

  • Configuration spécifique pour PHP5

    4 février 2011, par

    PHP5 est obligatoire, vous pouvez l’installer en suivant ce tutoriel spécifique.
    Il est recommandé dans un premier temps de désactiver le safe_mode, cependant, s’il est correctement configuré et que les binaires nécessaires sont accessibles, MediaSPIP devrait fonctionner correctement avec le safe_mode activé.
    Modules spécifiques
    Il est nécessaire d’installer certains modules PHP spécifiques, via le gestionnaire de paquet de votre distribution ou manuellement : php5-mysql pour la connectivité avec la (...)

Sur d’autres sites (10918)

  • Recoloring an image

    4 août 2023, par caffeinemachine

    I want to recolor a png image (which has handwritten text using a tablet) in a desired way (based on some dictionary [See color_dict in the code below] which dictates which color should be replaced by which ones).

    


    It was easy to write a code which would ask the color of each pixel and recolor the pixel according to the dictionary.

    


    But the output image ended up being pixelated (that, is, the text has jagged boundaries).

    


    Upon some googling I found that if one changes the colors using a linear function based on the RGB values then jaggedness can be avoided.

    


    A linear function ended up being inadequate for my purpose.

    


    So I resorted to using a quadratic function based on RGB values (one degree 2 polynomial in three variables for each color channel) as given in the following code.

    


    


    The problem is that it takes about 7 seconds to process one image, which is too high for my purpose.

    


    


    Even with multiprocessing the run time is high for my needs (which is to recolor a video, I tried the geq filter in ffmpeg but that also led to jaggedness in the output, even when inverting colors).

    


    Is there some other way to recolor the image (with the recipe of recoloring the same) ?

    


    Is there an advantage in using non-command line tools for this purpose ?

    


    from PIL import Image
import numpy as np


def return_row(r, g, b):
    r_inv = 255 - r
    g_inv = 255 - g
    b_inv = 255 - b
    return [r_inv**2, g_inv**2, b_inv**2, r_inv * g_inv, g_inv * b_inv, b_inv * r_inv, r_inv, g_inv, b_inv]


def solve_mat(dictionary):
    A = []
    B = []
    for key, color_code in dictionary.items():
        r = color_code[0]
        g = color_code[1]
        b = color_code[2]
        value = color_code[3]
        row = return_row(r, g, b)
        A.append(row)
        B.append(value)

    X = np.linalg.lstsq(A, B, rcond=None)[0]
    return X


def get_individual_channgel_dict(color_change_dict):
    r_dict = {}
    g_dict = {}
    b_dict = {}
    for color, array in color_change_dict.items():
        r_dict[color] = array[:3]
        r_dict[color].append(array[3])

        g_dict[color] = array[:3]
        g_dict[color].append(array[4])

        b_dict[color] = array[:3]
        b_dict[color].append(array[5])

    return r_dict, g_dict, b_dict


def get_coeff_mat(r_dict, g_dict, b_dict):
    r_mat = solve_mat(r_dict)
    g_mat = solve_mat(g_dict)
    b_mat = solve_mat(b_dict)

    return r_mat, g_mat, b_mat


def rgb_out(R, G, B, param_mat):
    a = param_mat[0]
    b = param_mat[1]
    c = param_mat[2]
    d = param_mat[3]
    e = param_mat[4]
    f = param_mat[5]
    g = param_mat[6]
    h = param_mat[7]
    i = param_mat[8]

    return int((a * (R**2)) + (b * (G**2)) + (c * (B**2)) + (d * R * G) + (e * G * B) + (f * B * R) + (g * R) + (h * G) + (i * B))


def change_colors_in_one_image(image_path):
    with Image.open(image_path) as img:
        pixels = img.load()

        # Iterate over each pixel
        width, height = img.size

        for x in range(width):

            for y in range(height):
                r, g, b = pixels[x, y]

                new_r = rgb_out(r, g, b, r_mat)

                new_g = rgb_out(r, g, b, g_mat)

                new_b = rgb_out(r, g, b, b_mat)

                pixels[x, y] = (new_r, new_g, new_b)

        # Save the modified image
        img.save(image_path)

color_change_dict = {
    "white": [5, 98, 255, 240, 240, 240],
    "black": [255, 255, 255, 81, 92, 93],
    "red": [207, 54, 108, 52, 152, 219],
    "mud": [203, 103, 14, 203, 103, 14],
}

r_dict, g_dict, b_dict = get_individual_channgel_dict(color_change_dict)
r_mat, g_mat, b_mat = get_coeff_mat(r_dict, g_dict, b_dict)
change_colors_in_one_image(imge_path)


    


    As an example, following is an input image.
enter image description here
Following is the output after recoloring.
enter image description here

    


  • Running ffmpeg is as issue in C#

    18 juin 2014, par Abdul Wajid Lakha

    M new to work with ffmpeg. Here is my code.

    namespace WindowsFormsApplication4
    {
       public partial class Form1 : Form
       {
           public Form1() { InitializeComponent(); }

           private void button2_Click(object sender, EventArgs e)
           {

               string folderPath = "";
               FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
               if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
               {
                   folderPath = folderBrowserDialog1.SelectedPath;
                   label2.Text = folderPath;

               }


           }

           private void button1_Click(object sender, EventArgs e)
           {
               ProcessStartInfo psi = new ProcessStartInfo();
               psi.FileName = "\ffmpeg.exe";
               psi.Arguments = string.Format(@"-i mpegts" + textBox1 + "-map 0:p:2 -vcodec mpeg2video -s 720x576 -r 25 -acodec mp2 -ac 2 -f mpegts test.ts");
           }

           public string aac_path { get; set; }

           public object[] mp3_path { get; set; }
       }
    }

    But process is started but file dont know where it captures.?

    Kindly guide accordingly

  • using ffmpeg with python, Input buffer exhausted before END element found

    12 mars 2024, par Konstantin

    When I run this from command line everything is fine

    



    ffmpeg -i input.mp4 -f mp3 -ab 320000 -vn output.mp3 


    



    But when I call the same from python

    



    subprocess.call(['ffmpeg', '-i', 'input.mp4', '-f', 'mp3', '-ab', '320000', '-vn', 'output.mp3'])


    



    After several seconds converting I'm getting this error

    



    [aac @ 0x7fb3d803e000] decode_band_types: Input buffer exhausted before 
END element found
Error while decoding stream #0:1: Invalid data found when processing 
input
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fb3d8000000] stream 1, offset 0x80011d: 
partial file
input.mp4: Invalid data found when processing input


    



    Any ideas ?