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

  • Home
  • SEARCH
  • 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 6614551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:21:08+00:00 2026-05-25T20:21:08+00:00

Previously, i wrote a code for Local Binary Pattern(LBP) and Obtained a LBP image

  • 0

Previously, i wrote a code for Local Binary Pattern(LBP) and Obtained a LBP image and histogram. Now i would like to divide the image into 6×6 matrixes and obtain the LBP image and histogram for each 6×6 matrix. I written the code below. But it doesnt work that well.

    I2=imread('CropF.jpg');
    m=size(I2,1);
    n=size(I2,2);
    counter = 1; 
    for i=2:6:m-1
        for j=2:6:n-1
            for k=i:i+6
               for l=j:j+6
                 J0=I2(k,l);
                 I3(k-1,l-1)=I2(k-1,l-1)>J0;
                 I3(k-1,l)=I2(k-1,l)>J0;
                 I3(k-1,l+1)=I2(k-1,l+1)>J0; 
                 I3(k,l+1)=I2(k,l+1)>J0;
                 I3(k+1,l+1)=I2(k+1,l+1)>J0; 
                 I3(k+1,l)=I2(k+1,l)>J0; 
                 I3(k+1,l-1)=I2(k+1,l-1)>J0; 
                 I3(k,l-1)=I2(k,l-1)>J0;
                 LBP(k,l)=I3(k-1,l-1)*2^7+I3(k-1,l)*2^6+I3(k-1,l+1)*2^5+I3(k,l+1)*2^4+I3(k+1,l+1)*2^3+I3(k+1,l)*2^2+I3(k+1,l-1)*2^1+I3(k,l-1)*2^0;
               end
            end
            LBP=uint8(LBP);
            LBPv=reshape(LBP,1,size(LBP,1)*size(LBP,2));
            Hist=hist(LBPv,0:255);
            Hist1(counter,:)= Hist;
            fname = sprintf('HistInf%03d.mat', counter);      
            save(fullfile(BASE_DIR,fname), 'Hist');     
            counter = counter + 1; 
        end
    end
    save('C:\Users\Lakshmen\Documents\MATLAB\HistInfMain','Hist1');

I have an error like this : ??? Index exceeds matrix dimensions.

Morever, the value for m and n I get is 394 and 330. Hence the value i should get for counter is 55 which is what i get but I get the error said above.

  • 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-05-25T20:21:09+00:00Added an answer on May 25, 2026 at 8:21 pm

    I guess you are still working on the problem from your previous questions.

    I am assuming that m and n denote the size of the I2 matrix. If that is the case, then the issue here is with the two inner loops for the k and l variables. They go from the current values of i and j and go up to i+6 and j+6. But i and j themselves can reach m-1 and n-1 respectively thus you get “out of bound” errors.

    If I am correct, you need to change the upper bounds of the i,j for-loops:

    counter = 1;
    Hist1 = [];               %# you can probably pre-allocate a fixed size here
    for i=2:6:m-1-6
        for j=2:6:n-1-6
            for k=i:i+6
                for l=j:j+6
                    %#...
                end
            end
            %# ...
        end
    end
    %# ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previously I've asked about inserting a column into a dataset . I now have
I would like to write JavaScript code that flattens the DOM of an arbitrary
I originally wrote some code like this: class Foo { public: Foo() : m_buffer()
I would like to build a recursive descent parsing implementation of the dice notation
I've just been tasked with automating a reporting task at work. Previously, someone would
I'm trying to write some code that deletes an image off the hard-disk once
I'm trying to write some tests around some code previously written before I start
Currently, I have the following code... file_name = content.split('=')[1].replace('', '') #file, gotten previously fileName
How to write an ant task that removes files from a previously compiled JAR?
Previously I have asked to strip text from a field and convert it to

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.