Answers.Body: <p>There are probably many ways to combine classes.  Here is my suggestion:</p>
  <ol>
  <li>Figure out the mask pixel values for each of the classes you want to pool (e.g. <code>Rear Delt = 1</code>, <code>Middle Delt = 2</code>, <code>front delt = 3</code>)</li>
  <li>Next choose a &quot;recode&quot; pixel value of the pooled class that is not used for any other class (e.g., make all of them <code>1</code>).</li>
  <li>Loop through each mask file to (re)assign the &quot;recode&quot; value to a pixel if the pixel value is equal to the value determined in #1 above.</li>
  </ol>
  <p>As an aside, you should confirm that your recoding worked by visualizing the masks before and after the recode.</p>
  <p>Also, don't save the new mask file over your original mask file.  You never know when you may need the original again.</p>
  <p>Finally, there is a <a href="https://stackoverflow.com/questions/56167289/vectorising-the-python-code-for-modifying-masks-used-in-image-segmentation">SO post</a> on vectorizing this process.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-10T21:32:33.697Z
Answers.LastActivityDate: 2022-11-10T22:19:37.793Z
Answers.LastEditDate: 2022-11-10T22:19:37.793Z
Answers.UserDisplayName: Snehal Patel
Body: <p>So I have labeled the entire skeletal muscles in detail. For example instead of just labeling shoulders I have labeled:</p>
  <ul>
  <li>Rear Delt</li>
  <li>Middle Delt</li>
  <li>Front Delt</li>
  </ul>
  <p>but now you want all of the delts to be combined as one object, shoulder. Is there anyway to take all of the previous labeled images of laptops and combine them as one object?</p>
  <p>The why:
  We have a lot of objects that are close to one another and it's making the model pretty big and complex. I want to drastically reduce the number of objects in the model but I don't want to lose over 15,000 labeled instance segmentation images.</p>
  <p>thank you in advance</p>
  
Tags: <image-segmentation><data-labelling><mask-rcnn><coco-dataset>
Title: possible to combine multiple labeled objects as one object?
UserDisplayName: AdvilPLZ
ThreadText: # possible to combine multiple labeled objects as one object?
  
  (Asked by: username_0 on 2022-10-13)
  
  So I have labeled the entire skeletal muscles in detail. For example instead of just labeling shoulders I have labeled:
  
  * Rear Delt
  * Middle Delt
  * Front Delt
  
  but now you want all of the delts to be combined as one object, shoulder. Is there anyway to take all of the previous labeled images of laptops and combine them as one object?
  
  The why:
  We have a lot of objects that are close to one another and it's making the model pretty big and complex. I want to drastically reduce the number of objects in the model but I don't want to lose over 15,000 labeled instance segmentation images.
  
  thank you in advance
  
  **Tags:** image-segmentation, data-labelling, mask-rcnn, coco-dataset
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-11-10. Score: 1
  
  There are probably many ways to combine classes. Here is my suggestion:
  
  1. Figure out the mask pixel values for each of the classes you want to pool (e.g. `Rear Delt = 1`, `Middle Delt = 2`, `front delt = 3`)
  2. Next choose a "recode" pixel value of the pooled class that is not used for any other class (e.g., make all of them `1`).
  3. Loop through each mask file to (re)assign the "recode" value to a pixel if the pixel value is equal to the value determined in #1 above.
  
  As an aside, you should confirm that your recoding worked by visualizing the masks before and after the recode.
  
  Also, don't save the new mask file over your original mask file. You never know when you may need the original again.
  
  Finally, there is a [SO post](https://stackoverflow.com/questions/56167289/vectorising-the-python-code-for-modifying-masks-used-in-image-segmentation) on vectorizing this process.
  
  
  ---
  
  