how to join two image

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 个评论

i extract GLCM from rgb image in envi and merged in one folder but when open in matlab most image doesnt appear
@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:
DGM
DGM 2023-3-29
编辑:DGM 2023-3-29
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

请先登录,再进行评论。

回答(2 个)

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 个评论

He's probably looking at torn scraps of paper, which people have asked about before. Think dead sea scrolls or forensic reconstruction.
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.
Hey, Once we have used concatenation, how can we deconcatenate to obtain the exact previous images?
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)
ans = 1×2
256 256
newImg = cat(2, img256, img256); % Stitch side-by-side
size(newImg)
ans = 1×2
256 512
newImg = cat(1, img256, img256); % Stitch top-and-bottom
size(newImg)
ans = 1×2
512 256
DGM
DGM 2023-1-10
编辑:DGM 2023-1-10
@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.
Vaibhav
Vaibhav 2023-1-24
编辑:Vaibhav 2023-1-24
I used the cat function but the new image produced is changed in color
@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
Image Analyst 2014-5-13

0 个投票

Have you checked out these similar questions: http://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22torn%22

2 个评论

Not all posts are similar. I've gone through several threads with no answer because they've been tagged as similar.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Import, Export, and Conversion 的更多信息

编辑:

DGM
2023-3-29

Community Treasure Hunt

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

Start Hunting!

Translated by