image-processingimage-stitching

Image construction from two image of same object scanned at two resolution for micro and macro information


I have SEM Image scanned at two magnifications, similar to this sample image. I want to merge these into a single image so that I can have information on pores at small scales and large scale. I want to know how to create a single image from those 2D slices using python or Matlab.


Solution

  • You may use MATLAB estimateGeometricTransform example:

    % Read the images.
    I1 = rgb2gray(imread('macro.png'));
    I2 = rgb2gray(imread('micro.png'));
    
    % Reuse MATLAB example.
    original = I1;
    distorted = I2;
    
    % Detect and extract features from the original and the transformed images.
    % (Use more octaves and scales and lower threshold for improving robustness).
    ptsOriginal  = detectSURFFeatures(original, 'NumOctaves', 5, 'NumScaleLevels', 5, 'MetricThreshold', 10);
    ptsDistorted = detectSURFFeatures(distorted, 'NumOctaves', 5, 'NumScaleLevels', 5, 'MetricThreshold', 10);
    [featuresOriginal,validPtsOriginal] = extractFeatures(original,ptsOriginal);
    [featuresDistorted,validPtsDistorted] = extractFeatures(distorted,ptsDistorted);
    
    % Match and display features between the images.
    index_pairs = matchFeatures(featuresOriginal,featuresDistorted);
    matchedPtsOriginal  = validPtsOriginal(index_pairs(:,1));
    matchedPtsDistorted = validPtsDistorted(index_pairs(:,2));
    figure
    showMatchedFeatures(original,distorted,matchedPtsOriginal,matchedPtsDistorted)
    title('Matched SURF Points With Outliers');
    
    % Exclude the outliers, estimate the transformation matrix, and display the results.
    [tform,inlierPtsDistorted,inlierPtsOriginal] = estimateGeometricTransform(matchedPtsDistorted,matchedPtsOriginal, 'similarity');
    figure
    showMatchedFeatures(original,distorted, inlierPtsOriginal,inlierPtsDistorted);
    title('Matched inlier points');   
    
    %Recover the original image from the distorted image.
    outputView = imref2d(size(original));
    Ir = imwarp(distorted,tform,'OutputView',outputView);
    figure; imshow(Ir); 
    title('Recovered image');
    
    % Visualize it somehow...
    imshowpair(original, Ir)
    

    Result:
    enter image description here

    Note:
    I removed the text from the images manually.