00:00Hello guys, welcome back with me, Chow Chow 2025.
00:04Today we going learn how to mask a dominant part of the picture automatically in Comfy UI.
00:12Masking in Comfy.
00:14If only one image is pretty simple, just right click the image, then click open in Mask Editor.
00:20In Mask Editor, you could do masking like in Forge or Automatic 11.11.
00:26Just click, save to node then.
00:30But it will be difficult if you have a lot of image to mask.
00:36The problem also arise if the image is a result of generation.
00:40If the image is the result of generation, it will be impossible for you to mask it manually without disturbing
00:47the flow.
00:58There are actually a way to be able to mask dominant picture like character or prime object that located in
01:06the center from an image automatically.
01:08Whether it is original image or image, result of generation.
01:14It works most of the time.
01:17You can later edit the result image or join it with other image or background.
01:24First, you need to have Comfy UI, Comfy Manager and Cocoa Segmentation.
01:30I put the link of the workflow on the description so you can install all missing node using Manager.
01:42Now I will explain how it works.
01:45First, we need some image.
01:48We will segment this with one former Cocoa Segmental.
01:51The result will be a bunch of segment not focusing only on character.
02:20The next thing to do is convert the Thee, the segment based on its color to red segment.
02:26Green segment and blue segment.
02:29We do this by using convert image to mask and set up the channel according to red, green, blue.
02:36We are going to show how the mask shown by convert mask to image and put a preview image.
02:52We are going to subtract red and green mask using mask composite.
03:04Here are the results.
03:06Now we also subtract the red, green result with blue to get the next combination.
03:11is getting there.
03:19Now we combine the mask with solid color with value 0.5.
03:38Here are the results.
03:40Lastly, we are going to create only two color on the mask by using top binary mask.
03:46Light color will be white while dark color will be black.
03:51Adjust the threshold if you want.
03:53In this setting, I use one.
04:11Now you could use the mask of dominant image.
04:13Now you could get what you want.
04:14Whether the mask of dominant image.
04:17Or not the dominant one.
04:20You could use invert mask for this.
04:24Now we have both mask.
04:26We can use this mask for in painting.
04:29Or we could use the undominate mask to crop it with black or solid color to get only the dominant
04:35image.
04:36We could also use this to merge dominant image to a new background image.
04:56It's just like .
05:25You can use the magic of your color for the mask.
05:26It's like you can use it to have a new color.
05:54You
06:15You
06:16You might want to focus on your character only and not on the background.
06:21There's still a way to do this.
06:22We could use a second mask process.
06:27This time we use one former AD a 20K segmentor.
06:31And this time we only split between red and green and then solid color.
06:36The rest of the process is the same.
06:39And here are the results.
07:03It also work for our original picture.
07:31Of course, if you just want to remove a background.
07:34You could use image, rembg or remove background.
07:39Like this.
07:44There are many things that you could do with this.
07:47Just be creative.
07:50Anyway guys, that's it for today video.
07:55Don't forget to like, share and comment.
07:58See you on the next episode.
08:01And have a nice day.
08:03Please, subscribe.
Comments