Outils pour utilisateurs

Outils du site


issue116:c_c

Over the course of this last month, I’ve helped to take numerous photographs of hats for my mother, who is a milliner. In doing so, I’ve found a good set of tools for tethered shooting (controlling the camera via a computer), removing backgrounds, and, in general, enhancing shots a little. I previously used the Windows and OSX-only Adobe Creative Cloud, which I no longer pay for. So, I needed to find a new approach. Tethered Shooting For this, I investigated a few options - Darktable being the most familiar-looking. Unfortunately, it didn’t work with the Canon EOS 400D (a.k.a. Rebel XTi). After a bit more researching, I discovered gphoto2. This is a command-line tool that lets you remotely take photos - even setting frames and intervals. Perfect for taking both normal and timelapse photos. Some features work with only certain cameras, but the tool will tell you when you try to use it. How I used it was pretty simple - I simply ran: gphoto2 –capture-image-and-download –filename=”IMG.JPG”

Au cours du dernier mois, j'ai aidé à prendre de nombreuses photos de chapeaux pour ma mère, qui est chapelière. Ce faisant, j'ai trouvé un bon jeu d'outils pour la connexion lors de la prise de vue (en contrôlant l'appareil photo depuis l'ordinateur), la suppression du fond et, en général, pour une petite amélioration des clichés. Avant, j'utilisais Adobe Creative Cloud, qui ne fonctionne que sous Windows et OS X et que j'ai arrêté de payer. Aussi, j'avais besoin de trouver une nouvelle approche.

Connecter la prise de vue

Pour cela, j'ai analysé quelques options - l'aspect de Darktable étant le plus familier. Malheureusement, il ne fonctionne pas avec l'EOS 400D de Canon (alias Rebel XTi). Après une recherche complémentaire, j'ai découvert gphoto2. C'est un outil en ligne de commande qui vous laisse prendre vos photos à distance, même le réglage du cadrage et du séquencement. Parfait pour prendre des photos normales ou en accéléré (timelapse). Certaines fonctions ne marchent qu'avec certains appareils, mais l'outil vous le dit quand vous essayez de l'utiliser.

Ma façon de l'utiliser est assez simple, il me suffit de lancer :

gphoto2 –capture-image-and-download –filename=”IMG.JPG”

This resulted in the image (IMG.JPG) in the current working directory. I updated the filenames as I took photos, but, if you set up intervals, or take a batch of photos at once, it will auto-increment. By default, photos are called capt0000.jpg. It also offers a few preview options, though my camera didn’t support it. Instead, I simply use the viewfinder to adjust the zoom/focus, and relied on my tripod to keep everything steady between shots. Once the photo was taken and downloaded, I checked it and either moved on to the next hat, or took another photo. Overall, this was pretty painless, and felt easier and quicker to me than Lightroom did. If you don’t like the command-line, you may not appreciate this tool, but I would still recommend giving it a shot. If you find yourself using the same options over and over again, a small bash script could cut down on what you’re typing.

Le résultat est une image (IMG.JPG) dans le répertoire de travail courant. Je mettais à jour les noms de fichiers tout en prenant les photos, mais, si vous réglez des intervalles, ou pour prendre une rafale d'un coup, il s'auto-incrémentera. Par défaut, les photos sont appelées capt0000.jpg. Il offre quelques options de prévisualisation, bien que mon appareil ne les supporte pas. À la place, j'utilise simplement le viseur pour ajuster le zoom/focus, et fais confiance à mon trépied pour que tout reste fixe entre les clichés. Une fois la photo prise et téléchargée, je la vérifiais, puis j'en refaisais une ou je passais à un autre chapeau.

Généralement, c'était sans difficulté particulière, et me semblait plus facile et rapide qu'avec Lightroom. Si vous n'aimez pas la ligne de commande, vous risquez de ne pas apprécier cet outil, mais je vous recommanderais cependant d'y jeter un œil. Si vous avez tendance à utiliser répétitivement les mêmes options, un petit script bash pourrait réduire les frappes au clavier.

Background Removal The photos we took were taken on a black backdrop, which worked pretty well. However, if the photos are later used for an online shop, or if we find the background too dark, I wanted to investigate background removal - so we could swap out the background for something lighter. I was looking for a quick and easy solution, as opposed to using something like the GIMP and the foreground select tool. Unfortunately, the only such options I found were either Windows or macOS-only, or an online tool with a credit-based payment plan (for downloading the results). If you don’t mind paying for a tool and running it on another computer/OS, or are okay with paying for credits to download the photos from an online tool, you can check out: https://autoclipping.com/ https://clippingmagic.com/ PhotoScissor (software) Super PhotoCut (macOS-only) For those of us not able (or willing) to take those approaches, we have a few limited options. Either we can use GIMP, or ImageMagick, to remove the backgrounds.

Suppression du fond

Nos photos étaient prises sur un arrière-plan noir, ce qui fonctionnait plutôt bien. Cependant, pour des photos utilisées par la suite pour un magasin en ligne, ou si nous trouvions le fond trop sombre, j'ai voulu rechercher un suppresseur de fond - de sorte que nous puissions remplacer le fond par quelque chose de plus clair. Je cherchais une solution rapide et simple, contrairement à l'utilisation de quelque chose comme GIMP et l'outil de sélection du premier plan. Malheureusement, les seules solutions correspondantes que j'ai trouvées étaient sous Windows ou mac-OS, ou un outil en ligne avec une solution de pré-paiement (pour télécharger les résultats). Si vous ne craignez pas de payer un outil qui tourne sur un autre ordinateur/OS, ou de pré-payer le téléchargement des photos à partir d'un outil en ligne, vous pouvez tester : https://autoclipping.com/ https://clippingmagic.com/ PhotoScissor (logiciel). Super PhotoCut (uniquement pour macOS).

Pour ceux qui sont incapables d'adopter ces solutions (ou ne veulent pas), il y a un choix limité. On peut utiliser, soit GIMP, soit ImageMagik, pour retirer les arrières-plans.

Using ImageMagick If you’re planning to use ImageMagick, I would recommend taking the time to take an empty background photo. The reason for this is because ImageMagick can find the difference between two photos, and remove anything the same (i.e. the background). For the process, you can visit here. Unfortunately, I can’t use this approach, as I don’t have a background photo of the setup, and the lighting conditions varied from day to day. There are a variety of approaches you can use. If you have a relatively simple background, there are a few things you can do. For this example, I’m going to remove the textured background from an ArchLinux wallpaper I had lying around. The original image: Generating a difference mask: convert walmfmzzz.jpg \( +clone -fx 'p{0,0}' \) -compose Difference -composite -modulate 100,0 -alpha off difference.png

Utilisation d'ImageMagik

Si vous prévoyez d'utiliser ImageMagik, je vous recommanderais de prendre le temps de commencer avec une photo de l'arrière-plan seul, car ImageMagik peut faire la différence entre deux photos et enlever tout ce qui est commun (par ex. le fond). Pour le mode opératoire, vous pouvez regarder ici : http://www.imagemagick.org/Usage/masking/#known_bgnd. Malheureusement, je ne peux pas utiliser cette approche, car je n'ai pas pris de photo du fond d'écran lors de la mise en place, et les conditions de lumière changent de jour en jour.

Vous pouvez utiliser différentes méthodes. Si vous avez un fond relativement simple, il y a plusieurs choses que vous pouvez faire. Pour cet exemple, je vais enlever le fond texturé venant d'un fond d'écran ArchLinux qui traînait par là.

L'image d'origine :

Génération du masque des différences :

convert walmfmzzz.jpg \( +clone -fx 'p{0,0}' \) -compose Difference -composite -modulate 100,0 -alpha off difference.png

Turning the mask into a threshold map: convert difference.png -threshold 25% boolean_mask.png Note: play with the threshold here in order to reduce the selection to just the object you want. Overlay the map to the original image, and remove the background. convert walmfmzzz.jpg boolean_mask.png -alpha Off -compose CopyOpacity -composite walmfmzzz_threshold.png As you can see, it removed all of the background, and the object itself (the Arch logo) is still in pretty decent shape. You could now place it on a different background, or colorify just the object and place it back onto the original image. Unfortunately, I couldn’t get this approach working for more complex backgrounds.

Transformation du masque en carte de seuil :

convert difference.png -threshold 25% boolean_mask.png

Note : jouez avec le seuil pour réduire la sélection seulement à l'objet que vous voulez.

Superposez la carte sur l'image d'origine et retirez l'arrière-plan.

convert walmfmzzz.jpg boolean_mask.png -alpha Off -compose CopyOpacity -composite walmfmzzz_threshold.png

Comme vous pouvez le voir, cela enlève tout le fond, et l'objet lui-même (le logo Arch) a encore une forme très acceptable. Vous pouvez maintenant le placer sur un fond d'écran différent ou colorier juste l'objet avant de le replacer dans l'image d'origine. Malheureusement, je n'ai pas pu faire fonctionner cette méthode sur des arrières-plans plus complexes.

GIMP The process here is tedious, and not very effective (in my experience at least). There are a variety of ways to do it. There is a foreground select tool, where you can outline the object you want to keep, and it will do its best to give a good selection of it (which has never worked well for me). Or you can duplicate the layer, make it grayscale, and then play with levels or a paintbrush, until the object you want to keep is painted white, and everything else is black. Then create a layer mask on the original image layer, and copy & paste the grayscale layer into the mask. It should result in an okay cut-out of the object. Afterwards, you can zoom in and slowly paint anything in black or white with a small brush that should be transparent or visible. I don’t find this process to be an effective way to remove backgrounds for anything besides a single photo here and there, and it is extremely tedious when you have complex backgrounds - I often end up with a halo of visible background around the object, or else I get jagged edges from trying to paint it out.

GIMP

Ici, le mode opératoire est fastidieux et pas très efficace (au moins d'après mon expérience). Il y a de multiples façons de faire. Il y a l'outil de sélection du premier plan, où vous pouvez entourer l'objet que vous voulez garder et il fera de son mieux pour en faire une bonne sélection (ce qui n'a jamais bien marché dans mon cas). Ou, vous pouvez dupliquer le calque, le passer en niveaux de gris, et ensuite, jouer avec les niveaux ou avec un pinceau, jusqu'à ce que l'objet que vous voulez garder soit tout blanc et le reste tout noir. Créez ensuite un calque de masquage sur le calque de l'image originale, et copiez/collez le calque en niveaux de gris dans ce calque. Le résultat devrait être une découpe assez convenable de l'objet. Par la suite, vous pouvez agrandir et peindre lentement en noir et blanc avec un pinceau fin qui devrait être transparent ou visible.

Je ne trouve pas ce procédé très efficace pour enlever les arrières-plans sauf pour une seule photo de temps en temps, et c'est particulièrement pénible quand le fond d'écran est complexe ; je finis souvent avec un halo de fond visible autour de l'objet, ou, d'autres fois, je me retrouve avec des bords dentelés après avoir essayé de le repeindre.

Conclusion Gphoto2 is a wonderful solution for tethered capture - but unfortunately, I haven’t found an approach to removing backgrounds that is as quick and easy as the paid options I listed above. Depending on your preparation and the background you want to remove, you may be able to automate the process to some degree with ImageMagick. Do you know of a better way to do this? If so, I would be thrilled to hear about it. Feel free to email any questions, suggestions, or general comments to me at lswest34+fcm@gmail.com.

Conclusion

Gphoto2 est une merveilleuse solution pour contrôler la capture, mais, malheureusement, je n'ai pas trouver une méthode pour enlever les arrières-plans qui soit aussi simple et rapide que les solutions payantes listées plus haut. Suivant votre préparation et l'arrière-plan à retirer, vous pouvez peut-être automatiser quelque peu le procédé avec ImageMagik.

Connaissez-vous une meilleure solution pour le faire ? Si c'est le cas, je serais ravi d'en entendre parler. N'hésitez pas à m'envoyer toutes vos questions, suggestions ou commentaires généraux, par mail à lswest34+fcm@gmail.com.

issue116/c_c.txt · Dernière modification : 2017/01/12 11:28 de andre_domenech