예제 #1
0
    /**
      * Pour arranger les bords du haut
      * @param rgb1
      * @param rgb2
      * @param out
      * @param startLine
      * @return out
      */
    private image borderW(int[] rgb1, int[] rgb2, image imgOut, bool startLine)
    {
        int[] rgbRes = new int[_widthBorder*_heightBorder];

        for(int i=0; i<rgb1.Length/4; i++)
        {
            rgbRes[i] = ((int)(0.75*((rgb1[i] >> 16) & 0xff ) + 0.25*((rgb2[i] >> 16) & 0xff))<<16  //1ere colonne
                          | (int)(0.75*((rgb1[i] >> 8)  & 0xff ) + 0.25*((rgb2[i] >> 8)  & 0xff))<<8
                          | (int)(0.75*( rgb1[i]        & 0xff ) + 0.25*( rgb2[i]        & 0xff))
                          | (int)((rgb1[i] >> 24) & 0xff )<<24);
        }
        for(int i=rgb1.Length/4; i<2*rgb1.Length/4; i++)
        {
            rgbRes[i] = ((int)(0.5*((rgb1[i] >> 16) & 0xff ) + 0.5*((rgb2[i] >> 16) & 0xff))<<16
                          | (int)(0.5*((rgb1[i] >> 8)  & 0xff ) + 0.5*((rgb2[i] >> 8)  & 0xff))<<8
                          | (int)(0.5*( rgb1[i]        & 0xff ) + 0.5*( rgb2[i]        & 0xff))
                          | (int)((rgb1[i] >> 24) & 0xff )<<24);
        }
        for(int i=2*rgb1.Length/4; i<3*rgb1.Length/4; i++)
        {
            rgbRes[i] = ((int)(0.5*((rgb1[i] >> 16) & 0xff ) + 0.5*((rgb2[i] >> 16) & 0xff))<<16
                          | (int)(0.5*((rgb1[i] >> 8)  & 0xff ) + 0.5*((rgb2[i] >> 8)  & 0xff))<<8
                          | (int)(0.5*( rgb1[i]        & 0xff ) + 0.5*( rgb2[i]        & 0xff))
                          | (int)((rgb1[i] >> 24) & 0xff )<<24);
        }
        for(int i=3*rgb1.Length/4; i<rgb1.Length; i++)
        {
            rgbRes[i] = ((int)(0.25*((rgb1[i] >> 16) & 0xff ) + 0.75*((rgb2[i] >> 16) & 0xff))<<16
                          | (int)(0.25*((rgb1[i] >> 8)  & 0xff ) + 0.75*((rgb2[i] >> 8)  & 0xff))<<8
                          | (int)(0.25*( rgb1[i]        & 0xff ) + 0.75*( rgb2[i]        & 0xff))
                          | (int)((rgb1[i] >> 24) & 0xff )<<24);
        }

        if(startLine)
        //            imgOut.setRGB(0, nbLinesDone*(_patchSize-_widthBorder), _heightBorder, _widthBorder, rgbRes, 0, _heightBorder);
            imgOut.setRGB(rgbRes, 0, nbLinesDone*(_patchSize-_widthBorder), _heightBorder, _widthBorder, _heightBorder);
        else
        //            imgOut.setRGB(_nbPatchPasted*(_patchSize-_widthBorder), nbLinesDone*(_patchSize-_widthBorder), _heightBorder, _widthBorder, rgbRes, 0, _heightBorder);
            imgOut.setRGB(rgbRes, _nbPatchPasted*(_patchSize-_widthBorder),
                          nbLinesDone*(_patchSize-_widthBorder), _heightBorder, _widthBorder, _heightBorder);
        return imgOut;
    }
예제 #2
0
    //-----------------------------------------------------
    // Fonction qui génère une image 4 fois plus grande que l image d entrée
    // en effectuant des miroirs par rapport à l image d entrée
    //  @param image L'image d entrée
    //  @return duplicateImage L'image dupliquée
    //    private BufferedImage duplicateSample(BufferedImage image)
    private image duplicateSample(image img)
    {
        int[] rgb  = new int[(_sampleSize/2)*(_sampleSize/2)];
        //        rgb = image.getRGB(_sampleSize/2, _sampleSize/2, rgb, 0, _sampleSize/2);
        rgb = img.getRGB(rgb);

        rgb = removeArtifacts(rgb);         // enlève les pixels trop eloignés de la moyenne du sample

        //        image.setRGB(0, 0, _sampleSize/2, _sampleSize/2, rgb, 0, _sampleSize/2);
        img.setRGB(rgb);                  // image sans artefacts

        // -- Miroir par rap à Y --
        //        BufferedImage _inYmirror = new BufferedImage(_sampleSize/2, _sampleSize/2, BufferedImage.TYPE_INT_ARGB);
        image _inYmirror = new image(img); // Copie
        _inYmirror.MirrorY();

        //        BufferedImage _in4 = new BufferedImage(2*image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        image _in4 = new image(2*img.Width(), img.Height());
        //        _in4.getGraphics().drawImage(image, 0, 0, null);
        _in4.setPixels(img);
        //        _in4.getGraphics().drawImage(_inYmirror, _in4.getWidth()/2, 0, null);
        _in4.setPixels(_inYmirror, _in4.Width()/2, 0);        // TODO Vérifier si le résultat est correct

        // -- Miroir par rap à X --
        //        BufferedImage in5 = new BufferedImage(_sampleSize, _sampleSize/2, BufferedImage.TYPE_INT_ARGB);
        image in5 = new image(_in4);
        in5.MirrorX();

        //        BufferedImage duplicateImage = new BufferedImage(_sampleSize, _sampleSize, BufferedImage.TYPE_INT_ARGB);
        image duplicateImage = new image(_sampleSize, _sampleSize);
        //        duplicateImage.getGraphics().drawImage(_in4, 0, 0, null);
        duplicateImage.setPixels(_in4);
        //        duplicateImage.getGraphics().drawImage(in5, 0, _sampleSize/2, null);
        duplicateImage.setPixels(in5, 0, _sampleSize/2);

        return duplicateImage;
    }
예제 #3
0
    /**
      *
      * @param rgb1 patch deja collé dans out
      * @param rgb2 patch de in
      * @param out
      * @return out
      */
    private image borderH(int[] rgb1, int[] rgb2, image imgOut)
    {
        int[] rgbRes = new int [_widthBorder*_heightBorder];
        for(int i=0; i<rgb1.Length-3; i++)
        {
            rgbRes[i] = (  (int)(0.75*((rgb1[i] >> 16) & 0xff ) + 0.25*((rgb2[i] >> 16) & 0xff))<<16  //1ere colonne
                         | (int)(0.75*((rgb1[i] >> 8)  & 0xff ) + 0.25*((rgb2[i] >> 8)  & 0xff))<<8
                         | (int)(0.75*( rgb1[i]        & 0xff ) + 0.25*( rgb2[i]        & 0xff))
                         | (int)((rgb1[i] >> 24) & 0xff )<<24);
            i++;
            rgbRes[i] = (  (int)(0.5*((rgb1[i] >> 16) & 0xff ) + 0.5*((rgb2[i] >> 16) & 0xff))<<16
                         | (int)(0.5*((rgb1[i] >> 8)  & 0xff ) + 0.5*((rgb2[i] >> 8)  & 0xff))<<8
                         | (int)(0.5*( rgb1[i]        & 0xff ) + 0.5*( rgb2[i]        & 0xff))
                         | (int)((rgb1[i] >> 24) & 0xff )<<24);
            i++;
            rgbRes[i] = (  (int)(0.5*((rgb1[i] >> 16) & 0xff ) + 0.5*((rgb2[i] >> 16) & 0xff))<<16
                         | (int)(0.5*((rgb1[i] >> 8)  & 0xff ) + 0.5*((rgb2[i] >> 8)  & 0xff))<<8
                         | (int)(0.5*( rgb1[i]        & 0xff ) + 0.5*( rgb2[i]        & 0xff))
                         | (int)((rgb1[i] >> 24) & 0xff )<<24);
            i++;
            rgbRes[i] = (  (int)(0.25*((rgb1[i] >> 16) & 0xff ) + 0.75*((rgb2[i] >> 16) & 0xff))<<16
                         | (int)(0.25*((rgb1[i] >> 8)  & 0xff ) + 0.75*((rgb2[i] >> 8)  & 0xff))<<8
                         | (int)(0.25*( rgb1[i]        & 0xff ) + 0.75*( rgb2[i]        & 0xff))
                         | (int)((rgb1[i] >> 24) & 0xff )<<24);
        }

        //        out.setRGB(_nbPatchPasted*(_patchSize-_widthBorder), nbLinesDone*(_patchSize-_widthBorder), _widthBorder, _heightBorder, rgbRes, 0, _widthBorder);
        imgOut.setRGB(rgbRes, _nbPatchPasted*(_patchSize-_widthBorder),
                      nbLinesDone*(_patchSize-_widthBorder), _widthBorder, _heightBorder, _widthBorder);

        return imgOut;
    }