{"id":150,"date":"2024-09-03T18:28:02","date_gmt":"2024-09-03T18:28:02","guid":{"rendered":"https:\/\/www.mickiwiki.com\/?p=150"},"modified":"2024-09-05T18:47:46","modified_gmt":"2024-09-05T18:47:46","slug":"green-screen","status":"publish","type":"post","link":"https:\/\/www.mickiwiki.com\/?p=150","title":{"rendered":"Green screen"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You want to make objects with transparency you can add to something else. I don&#8217;t know if you are supposed to do it this way but seems like it might work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Photograph object on green<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"601\" src=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/greenBG.png\" alt=\"\" class=\"wp-image-151\" srcset=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/greenBG.png 400w, https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/greenBG-200x300.png 200w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">remove the green<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/perl\nuse strict;\nuse warnings;\nuse Image::Imlib2;\nuse feature \"say\";\n#can read directory and make an array of images, @files\nmy ($image); \nmy $file1=(\".\/_MG_7784.png\");\n\n#for (my $i=0;$i&lt;=$#files;$i++){\n#$file=$files&#91;0];\nsay $file1;\nmake_transparent($file1);\n$image-&gt;save(\"Wood_trans.png\");\nsay \"done\";\nexit;\n\n\nsub make_transparent{\nmy $file=$_&#91;0];\nsay $file;\n$image=Image::Imlib2-&gt;load($file);\n$image-&gt;has_alpha(1);\n$image-&gt;will_blend(0);\n$image-&gt;set_colour(0,0,0,0); \nmy $width = $image-&gt;width;\nmy $height = $image-&gt;height;\nfor my $y (0 .. $height - 1) {\n# can experiment with the RGB values\t\n   for my $x (0 .. $width - 1) {\n     my  ($red, $green, $blue, $alpha) = $image-&gt;query_pixel($x, $y);\n     #say \"$red, $green, $blue, $alpha\";\n     #if($green&gt;200 &amp;&amp; $red&lt;50 ||$green&gt;200 &amp;&amp; $blue&lt;100 ||$green&gt;235  ){ \n #    if($green&gt;100 &amp;&amp; $red&lt;$green){\n  if($green&gt;100&amp;&amp;$red&lt;40){      \n         $image-&gt;draw_point($x, $y);\n           }\n #          if($green&gt;100 &amp;&amp; $red==0){ \n#\t\t$image-&gt;draw_point($x, $y);\t   \n#    }\n    }\n  }\t\nreturn;\t\n\t}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"696\" src=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/transparent_with_green-1.png\" alt=\"\" class=\"wp-image-157\" srcset=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/transparent_with_green-1.png 462w, https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/transparent_with_green-1-199x300.png 199w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">there are issues in that the green is reflected in the object. I tried linear polarising filter on the lights and the lens which seems to help a bit. What seems to work is to photograph the object first on a white\/neutral background.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"601\" src=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_whiteBG.png\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_whiteBG.png 400w, https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_whiteBG-200x300.png 200w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">can make a palette from that to use with ffmpeg.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i whiteBG.png -vf \"palettegen=max_colors=256:reserve_transparent=1\" -frames:v 1 palette.png<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">this makes a 16&#215;16 pixel image which is shown bigger here<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"200\" src=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/palette_big.png\" alt=\"\" class=\"wp-image-154\" srcset=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/palette_big.png 200w, https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/palette_big-150x150.png 150w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">and apply that to the transparent image that has green<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/perl\nuse strict;\nuse warnings;\n\nmy $ffmpeg_command=\"ffmpeg -y -f concat -safe 0 -i image_list.txt -i palette.png -filter_complex \\\"&#91;0:v]scale=1936:-1,setsar=1&#91;vid];&#91;vid]&#91;1:v]paletteuse\\\"  save_name%04d.png\";\nsystem($ffmpeg_command);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">image_list.txt is a list of files preceded by &#8220;file&#8221;. I just have it like that if want to change more than one file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>file .\/images\/Wood.png\nfile .\/images\/_MG_7784.png<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"395\" height=\"597\" src=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_trans_no_green-1.png\" alt=\"\" class=\"wp-image-159\" srcset=\"https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_trans_no_green-1.png 395w, https:\/\/www.mickiwiki.com\/wp-content\/uploads\/2024\/09\/small_trans_no_green-1-198x300.png 198w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Wants refining a bit but looks like might work<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You want to make objects with transparency you can add to something else. I don&#8217;t know if you are supposed to do it this way but seems like it might work. Photograph object on green remove the green there are issues in that the green is reflected in the object. I tried linear polarising filter&hellip;&nbsp;<a href=\"https:\/\/www.mickiwiki.com\/?p=150\" rel=\"bookmark\"><span class=\"screen-reader-text\">Green screen<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=150"}],"version-history":[{"count":4,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mickiwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}