Info

This question is closed. Reopen it to edit or answer.

How to conncet two images?

2 views (last 30 days)
Lolipop
Lolipop on 15 May 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi!
I would like to know is there a way to connect two images. So when user picks the image (e.g mar-001-100) from one directory I would like to work with image from another directory (e.g mar-001-100-contour). So I want to connect these two images. In that way I can work with second image and display to user first image.

Answers (2)

Image Analyst
Image Analyst on 15 May 2015
Yes. I don't know how your user picked the image, but if it was from a listbox (hopefully because that's the most convenient for your user), you know the folder1 and base filename. If you made the user use uigetfile() then you can get the base filename and folder1 from there. So you can either get the base filename from the 'Value' and 'String' property of the listbox, or from the return argument of uigetfile. Now, you must know the folder name of the second folder you want to use, so you simply use that one when you construct the full filename with fullfile():
fullFileName2 = fullfile(folder2, baseFileName);
Then use that however you need to.
  2 Comments
Lolipop
Lolipop on 15 May 2015
I have four bases of images and only two of them I need to connect. Other two bases are not connected and I use it in normal way with uigetfile and list box. Problem is how to connect these two bases. The solution you gave it to me works when I want all bases of images to connect. I hope, I was clear enoguh. Please if you don't understand me what I am trying to do, tell me and I will try to explain better. Thank you!
Image Analyst
Image Analyst on 15 May 2015
I'm not sure I understand why what I said won't work. Just use fullfile() with whatever folder you want to construct new filenames.

Walter Roberson
Walter Roberson on 15 May 2015
[pathstr, name, ext] = fileparts(ThePickedFile);
corresponding_file = fullfile(pathstr, [name, '_contour' ext])

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!