How to select one image on montage and choose between the multiple images to select?
9 views (last 30 days)
Show older comments
Hello everyone! How to select one image on montage and choose between the multiple images to select, please?It's my problem now! Please send me the code to my email please. Thanks. friedman.maharilaza@gmail.com
0 Comments
Answers (1)
Elisa
on 28 Nov 2025 at 15:39
A little late for the person posting the question, but I had the same question and when unable to find a good answer, I wrote a small function to suit me. I'm sharing it for others to benefit. See the attached m-file.
Notes:
Create your montage adding a *single* pixel black border to each:
montageImage = montage(catImages,'Bordersize',[1 1]);
Pass this image into the function:
imgNum = selectMontage(montageImage)
The function will display the montage image in a new figure.
You will be prompted to select the subimage of interest by clicking with the mouse (ginput).
The number the subimage is in the sequence that formed the montage will be returned.
3 Comments
Elisa
on 29 Nov 2025 at 19:55
My solution may not solve all cases, and I think there was a gap as I converted what I was doing interactively into a function, but given that NOBODY had answered this question in 7 years and I didn't find anything else relevant online, it was offered to help people move forward a little. I found determining how many images wide vs tall were in the montage, and thus the element size, to be the most difficult part of solving the problem.
DGM
7 minutes ago
I appreciate that specific kind of motivation you mention. It's why I'm here. Had a problem, couldn't find anything in searches, wound up solving it in a days-long fit of madness, then went to find a place to testify.
I know that I often come across as a jerk, but sometimes the impression is more than intended. Apologies if that's what's happened. I suppose I have been too accustomed to barking at AI-generated slop answers these days, but being so reflexive is not fair in this case.
The utility is a start, but I want to offer ways to help you improve it, or if you consider it finished for your purposes, to help future readers make it work for them. Things like the example in the synopsis could easily lead someone into confusion. Explaining the different ways fixes could be approached seemed more illustrative than just writing my own complete answer and saying "no, use this".
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!