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 4032514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:43:51+00:00 2026-05-20T11:43:51+00:00

I have a section of code that finds Harris corners in a sequence of

  • 0

I have a section of code that finds Harris corners in a sequence of images. I need to do this for 92 images, but it’s rather slow. As such, I’d like to run the code in parallel. The code I have below has an error related to the variable “corners”

%% Harris corners
    max_pts = 900;
    corners = zeros(max_pts,2,size(images,3));
    parfor i = 1:size(images,3)
        I = images(:,:,i);
        [y x] = get_corners(I,max_pts);
        corners(1:length(y),:,i) = [y x];
    end

Which says:

MATLAB runs loops in parfor functions by dividing the loop iterations into groups, and then sending them to MATLAB workers where they run in parallel. For MATLAB to do this in a repeatable, reliable manner, it must be able to classify all the variables used in the loop. The code uses the indicated variable in a way that is incompatible with classification.
Suggested Action
Fix the usage of the indicated variable.
For more information about variable classification and other restrictions on parfor loop iterations, see “Classification of Variables” in the Parallel Computing Toolbox documentation.

Any ideas how to fix this?

Thanks!

  • 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-20T11:43:51+00:00Added an answer on May 20, 2026 at 11:43 am

    As mentioned by @Chris, the line

    corners(1:length(y),:,i) = [y x];
    

    is the problem. An easy way to make sure corners is sliceable is to use a cell array

    max_pts = 900;
    cornerCell = cell(size(images,3),1);
    parfor i = 1:size(images,3)
        I = images(:,:,i);
        [y x] = get_corners(I,max_pts);
        cornerCell{i} = [y x];
    end
    

    If you don’t want corners to be a cell array (note that to plot corners for the ith image, you can call imshow(images(:,:,i),[]),hold on, plot(cornerCell{i}(:,1),cornerCell{i}(:,2),'o')), you can always convert back to your original 900-by-2-by-nImages array in a loop that won’t cost you any noticeable time:

    corners = zeros(max_pts,2,size(images,3));
    for i=1:size(images,3)
       corners(1:size(cornerCell{i},1),:,i) = cornerCell{i};
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a section of code that I need to remove from multiple files
I have a section of code that is being used to determine if a
I have a section of makefile that has this sort of structure: bob: ifdef
Interesting situation. I have a section of code that creates several ZipOutputStreams. As a
I have a section of code that depending on the URL requested, will include
I have a section of code that I would not like to run if
I have following Code Block Which I tried to optimize in the Optimized section
I have a set of data protected by 16bit checksums that I need to
i have a input tag which is non editable, but some times i need
I have a Jtree with nodes representing images that the user can call up

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.