Replace the image background
Ältere Kommentare anzeigen

3 Kommentare
Marceline
am 8 Dez. 2022
I don't mind helping. That's what we're here for.
That said, most people are going to expect a show of effort in cases of homework. Showing your work isn't just a token obligation to labor. It's a means of communicating your thought process and the scope of your current understanding. Dumping the assignment in whole without explanation tends to rub people the wrong way.
If you want something more specific than what's given, you're still free to add more description about where you are in the task, or what specifically you want help with. You're free to attach copies of your code in progress and the source images (if they exist).
As I mentioned in the answer, this isn't an easy composition to do with basic techniques. It's hard for me to know if the other parts of the assignment suggest a specific approach to the task. It's also hard to know how perfect the results need to be. You have the opportunity to clear that up as well.
For what it's worth, I gravitate toward these sorts of image composition/adjustment questions, and I tend to be open about my criticism of the assignments and presentation. I expect that you understand that I know you weren't the one who decided to put a midget giraffe in Tennessee.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 7 Dez. 2022
Bearbeitet: Image Analyst
am 8 Dez. 2022
0 Stimmen
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.
Here are the basic steps of one way to do it, which might be the easiest for you to understand, but by no means the most compact or only way to do it.
- Use the Color Thresholder on the Apps tab of the tool ribbon to find the blue background. Export the masking function.
- Get the mask and scan it pixel by pixel with a double for loop. If the pixel is black (meaning it's in the giraffe), take that pixel and paste in into the underlying target forest image.
[EDIT] See my generic attached demo. Adapt as needed, if you want.

4 Kommentare
DGM
am 8 Dez. 2022
It's a lot easier to fit an object back into the scene it came out of, isn't it? :D
Image Analyst
am 9 Dez. 2022
@DGM, not really easier -- the operations would be the same, for this simple copy and paste operation, as if the background had been a totally unrelated image, as long as it was the same size. I just used this one because for my general purpose demo, it was one that ships with MATLAB.
Granted there may be edge effects for a wildly different background because it doesn't do any anti-aliasing or blending of the edges so there could be some sharp outlines that may be noticeable or even objectionable. But I find I need to keep my general purpose demos as simple as possible otherwise people have trouble following them. That's why I didn't put in code to smooth/blend the edges. I doubt it would be required or expected for the homework assignment. However for best output image quality you would want to do that, and you showed how to do that nicely.
DGM
am 9 Dez. 2022
That's fair enough. It's the difficulties with certain compositions that tend to interest me more than the questionable objectives of an assignment. A lot of these things boil down to making a mountain out of avoiding using 20 seconds of brushwork.
Does that separated version of llama.jpg come wtih the newer versions, or was that something you made/obtained elsewhere?
Image Analyst
am 9 Dez. 2022
I made the separate foreground and background images, from the original MATLAB demo image, in Adobe Photoshop. It was quicker to do that way than to write code to do it in MATLAB.
Kategorien
Mehr zu Image Segmentation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



