Add segmentation map processing to SAM Image Processor
Author: rwood-97
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

Fixes #27361 

## Before submitting
- [ ] ~This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).~
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@amyeroberts

Comments:
@rwood-97 - thanks for opening this PR - let me know when it's ready for review! 

@amyeroberts I've added a very small amount to the tests. I think they could be more comprehensive but I think at min this now tests a case of input with/without masks. Let me know if there are any others you'd want me to add.

Will also do docs asap then will make as ready for review

Hey, just looking through the current documentation on SAM and I think the most relevant place for me to add docs is probably [this tutorial](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/SAM/Fine_tune_SAM_(segment_anything)_on_a_custom_dataset.ipynb). I'll create an issue on that repo once this PR is done so I think this PR could be considered as ready now.

@rwood-97 Regarding where to document, the best place would be to add an example on the [model doc page](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/sam.md) and/or in the officially supported notebooks - [here](https://github.com/huggingface/notebooks/blob/main/examples/segment_anything.ipynb) and [here](https://github.com/huggingface/notebooks/blob/main/examples/automatic_mask_generation.ipynb). 

Could you add a small code snippet to the model doc page to show how to pass and use the masks? After that we can merge :) 

The notebook you linked to isn't officially maintained by Hugging Face. You can certainly still open a PR to add to it if you'd like! 

yep sure, I'll try find some time this week/next week for this 

All done 👍 

@rwood-97 Thanks again for all the work on this contribution!