How to automatically mask a character or dominant part of the picture in ComfyUI

Channel:
Subscribers:
3,250
Published on ● Video Link: https://www.youtube.com/watch?v=DsoV3xaEnas



Duration: 8:07
240 views
11


Hello Guys welcome back with me ChowChow 20-25

Today we going learn how to mask a dominant part of the picture automatically in Comfy U I
Masking in Comfy U I if only one image is pretty simple, just right click the image then click open in Mask Editor
In Mask Editor you could do masking like in forge or automatic 11 11
Just Click Save to node then

But it will be difficult if you have a lot of image to mask.
The problem also arise if the image is a result of generation
If the image is the result of generation, it will be impossible for you to mask it manually without disturbing the flow

There are actually a way to be able to mask dominant picture like character from an image automatically
Whether it is original image or image result of generation
It work most of the time
You can later edit the result image or join it with other image or background

How to do it?
First you need to have Comfy U I, Comfy Manager and Coco Segmentation.
I put the link of how to install them in the video description
I also put the link of the workflow on the description so you can install all missing node using manager

Now i will explain how it works
first, we need some image
We will segment this with One Former Coco segmentor
The result will be a bunch of segment not focusing only on character

The next thing to do is convert the the segment based on it's color to red segment, green segment and blue segment
We do this by using Convert Image To Mask and set up the channel according to Red Green Blue
We going to show how the mask shown by convert mask to image and put a preview image

Next we going to substract Red and Green mask using mask composite
here are the result
Now we also substract the Red Green result with Blue to get the next Combination
is getting there
Now we combine the mask with solid color with Value 0.5
here are the result
lastly we going to create only two color on the mask by using ToBinaryMask
Light color will be white while dark color will be black
adjust the threshold if you want
in this setting i use 1

Now you could get what you want, whether the mask of dominant image
or the not the dominant one
You could use invert mask for this
Now we have both mask
we can use this mask for inpainting
or we could use the undominat mask to crop it with black or solid color to get only the dominat image
we could also use this to merge dominant image to a new background image

You might to focus on your character only, and not on the background,
there still a way to do this
We could use a second mask process
this time we use One Former ADE20K Segmentor
And this time we only split between red and green and then solid color
the rest of the process is the same
and here are the result

It also work for our original picture
Off course if you just want to remove a background
You could use Image Rem b g or Remove Background
like this

There are many thing that you could do with this
Just be creative


Anyway guys, that's it for today video
thank you for watching
don't forget to like, share and comment
see you on the next episode
and have a nice day
please subscribe




Other Videos By CaoCao2025


2024-07-24Persona 5 Royal Ep 319 Shopping With Sumire | Billiard with Everyone
2024-07-24How to Swap Face in Automatic1111 or Forge using Reactor (Better than roop)
2024-07-23Suikoden 2 - 121 Luca Blight forbid Sailing
2024-07-22How to Make a Pose for Controlnet using Automatic1111 3D OpenPose Extension
2024-07-22Persona 5 Royal Ep 318 Boxercising with Sumire | Studying at Diner in Shibuya Central Street
2024-07-21Persona 5 Royal Ep 317 Praying at Meiji Temple | Capturing Guardian Fish
2024-07-21AI Dance Girl Generation 13 - Good Result, inconsistent, failed twirl #DancingAI #Dance
2024-07-20Suikoden 2 - 120 What Nanami want
2024-07-19VioletViolet Realistic Character Dancing #DancingAI #Violet #PokeDance
2024-07-18Xenosaga Episode 3 #2 Prolog : Scientia
2024-07-17How to automatically mask a character or dominant part of the picture in ComfyUI
2024-07-16Suikoden 2 - 119 Nanami Still believe Jowy
2024-07-15Persona 5 Royal Ep 315 Haru Third Awakening | Jazz Club
2024-07-15How to generate Character in certain Age in Stable Diffusion With Age Slider Lora
2024-07-14Persona 5 Royal Ep 314 Makoto Third Awakening | Brewing Master Coffee
2024-07-14AI Dance Girl Generation 12 - face focus, expression, glass #DancingAI #Dance #CallMe
2024-07-13Suikoden 2 - 118 Riou, Jowy and Nanami forced to leave Jowy in Muse
2024-07-12Ann Takamaki Realistic Character Dancing #DancingAI #AnnTakamaki
2024-07-11Xenosaga Episode 3 #1 Story so far
2024-07-11Persona 5 Royal Ep 313 Yusuke Third Awakening | Golfer Sarutahiko
2024-07-10How to Create an Open Pose Video for Animate Anyone or Animatediff using Control Net



Tags:
stable diffusion
ai art
ai generation
art creation
caocao2025
automatic1111
ai
LORA
civitai
Forge
ComfyUI
text2image
GTX 1660 Super
RTX
RTX 4060 TI
mask
masking