how to join two image
Show older comments
I have two fragments of one image, i want join these two piece. someone please tell me how to join these two fragments.
thanks in advance
3 Comments
heba
on 28 Mar 2023
i extract GLCM from rgb image in envi and merged in one folder but when open in matlab most image doesnt appear
Image Analyst
on 29 Mar 2023
@heba If you have any more questions, start a new question and then attach your data and code to read it in with the paperclip icon after you read this:
There isn't enough information to provide an answer as-is, but this probably should be posted as a new question anyway.
I'd suggest starting a new question by using the 'Ask' link at the top of the page. When you do, provide an explanation of the specifics.
- what files you have (provide examples that work/don't work if possible)
- attach a minimal code example that demonstrates the problem
- describe the specific goals, expectations, observations
Answers (2)
Benjamin Avants
on 13 May 2014
You should use the cat() function.
if your images are A and B and you want to merge them so that you get AB (A on the left with be on the right) the command looks like this:
newImg = cat(2,A,B);
If you want A on top of B:
newImg = cat(1,A,B);
8 Comments
Image Analyst
on 13 May 2014
He's probably looking at torn scraps of paper, which people have asked about before. Think dead sea scrolls or forensic reconstruction.
Benjamin Avants
on 13 May 2014
Edited: Benjamin Avants
on 13 May 2014
If Image Analyst is correct, the solution to your problem is much more complicated and will take a great deal of work to implement. To my knowledge, no such algorithm has been submitted as a File Exchange program.
If the two pieces are aligned and sized the same, you may be able to merge them manually by displaying them both in the same figure and shifting one of the images until it is properly lined up with the other one. Knowing the offsets, you could then merge the image data using those offsets to end up with your final image. Obviously this would be impractical if you have many such pieces to align. It also would not work well if the image pieces are rotated at all or are scaled differently.
The merging process would also be non-trivial, as a decision would need to be made for each overlapping pixel as to which pixel should be incorporated into the final image.
V VENKATA KRISHNAN 14BEC0060
on 17 Feb 2018
Hey, Once we have used concatenation, how can we deconcatenate to obtain the exact previous images?
Vivek
on 10 Jan 2023
It gives the size of image 256*512 if I concatenate the two fragmented image of size 256*256. So your code is wrong.
@Vivek why is that wrong? If I have a 256x256 image on the left half, and another 256x256 on the right half, there will be 256 rows and 512 columns. Why do you say that is wrong? If not 256x512, then what size do you think it should be?
img256 = imread('cameraman.tif');
size(img256)
newImg = cat(2, img256, img256); % Stitch side-by-side
size(newImg)
newImg = cat(1, img256, img256); % Stitch top-and-bottom
size(newImg)
@Vivek Note that out of four people to ask about this task in this thread, to date, none have provided an example of what they're working with. Not one image. Not one line of code.
If you want to concatenate two compatibly-sized images, the area of the result is the sum of the areas. It's that simple. If you're trying to do something more complicated than concatenation, you should recognize that it's more complicated; reorienting and stitching image fragments is obviously not a problem that gets solved in one line.
You should also recognize that it's up to you to communicate your task using specific details. While it's unlikely that anyone will gift you a bespoke implementation for a complicated project, a minimal-effort question limits how helpful anyone can be.
Image Analyst
on 24 Jan 2023
@Vaibhav it should not change the absolute color. Are both your images RGB? Or is one gray scale? Are both in a similar value range, like 0-1 or 0-255, or 0-65535? If the ranges are way different, then one may appear a lot darker than the other. If you still have problems, attach your code and both your images and create a new discussion thread.
Image Analyst
on 13 May 2014
0 votes
Have you checked out these similar questions: http://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22torn%22
2 Comments
nicole
on 21 Oct 2022
Not all posts are similar. I've gone through several threads with no answer because they've been tagged as similar.
Image Analyst
on 21 Oct 2022
@nicole If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Try this:
Categories
Find more on Import, Export, and Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!