Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:27:50+00:00 2026-06-02T04:27:50+00:00

Actually i am trying to implement the code on the following website http://www.mathworks.com/matlabcentral/fileexchange/28300 but

  • 0

Actually i am trying to implement the code on the following website http://www.mathworks.com/matlabcentral/fileexchange/28300 but this works only when two images given have the same dimensions , i want to make this code work where one image has some dimension and other has some other dimension, if i do this with current code, it gives the error

??? Sub scripted assignment dimension mismatch. Error in ==> example2 at 27

Line 27:

I(:,1:size(I1,2),:)=I1; I(:,size(I1,2)+1:size(I1,2)+size(I2,2),:)=I2; 

can you resolve this for me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:27:51+00:00Added an answer on June 2, 2026 at 4:27 am

    You can try padding the smaller image with zeros so that is has the same dimensions as the larger image. For example

    %Start with rows:    
    if size(I1,1) > size(I2,1) %I1 has more rows so pad I2
            pad = zeros (size(I1,1) - size(I2,1), size(I2,2));
            I2 = [I2 ; pad]; %Append the rows of zeros to the bottom of I2
    else %I2 has more rows so pad I1
            pad = zeros (size(I2,1) - size(I1,1), size(I1,2));
            I1 = [I1 ; pad]; %Append the rows of zeros to the bottom of I1
    
    %Pad the columns    
    if size(I1,2) > size(I2,2) %I1 has more rows so pad I2
            pad = zeros (size(I2,1), size(I1,2) - size(I2,2));
            I2 = [I2 , pad]; %Append the columns of zeros to the left of I2
    else %I2 has more rows so pad I1
            pad = zeros (size(I1,1), size(I2,2) - size(I1,2));
            I1 = [I1 , pad]; %Append the columns of zeros to the left of I1
    

    I haven’t tested that though so you might need to fiddle a bit to get the dimension perfect, like maybe size(I2,2) – size(I1,2) + 1 instead of size(I2,2) – size(I1,2), that sort of thing.

    But you need to first figure out the logic of what you are trying to do. Padding with zeros might not make sense in your application. Also my code pads on the bottom and the left but you might want to pad all the way around so your image is in the centre of the new image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the logging approach at http://www.cimgf.com/2010/05/02/my-current-prefix-pch-file/ . I'm not sure how
I was trying out the following code which actually saves the pdf file to
I am trying to implement text to speech by following this article on the
i am trying to implement following Code... String updateQuery =INSERT INTO MAAccounts(userId, accountId, accountType,
I'm trying to implement this singleton class. But I encountered this error: 'Singleton::~Singleton': cannot
Actually I'm trying to implement an ontouchlistener into my android (1.5) application. therefore i
I'm actually trying to fix this issue where my projects are always out of
I'm trying to prevent A HREF from actually opening the link, but to execute
I'm trying to implement jqgrid search on MVC, following the interesting answer by @Oleg,
I am trying to implement the following logic in C++. Here x and y

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.