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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:11:48+00:00 2026-06-15T09:11:48+00:00

Given a matrix where 1 is the current subset test = 0 0 0

  • 0

Given a matrix where 1 is the current subset

test =

     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     1     1     0     0
     0     0     1     1     0     0
     0     0     0     0     0     0
     0     0     0     0     0     0

Is there a function, or quick method to get change the subset to the boundary of the current subset?

Eg. Get this subset from ‘test’ above

test =

     0     0     0     0     0     0
     0     1     1     1     1     0
     0     1     0     0     1     0
     0     1     0     0     1     0
     0     1     1     1     1     0
     0     0     0     0     0     0

In the end I just want to get the minimum of the cells surrounding a subset of a matrix. Sure I could loop through and get the minimum of the boundary (cell by cell), but there must be a way to do it with the method i’ve shown above.

Note the subset WILL be connected, but may not be rectangular. This may be the big catch.

This is a possible subset…. (Would pad this with a NaN border)

test =

     0     0     0     0     0     0
     0     0     0     0     0     0
     0     0     1     1     0     0
     0     0     1     1     0     0
     0     0     1     1     1     1
     0     0     1     1     1     1

Ideas?

  • 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-15T09:11:49+00:00Added an answer on June 15, 2026 at 9:11 am

    The basic steps I’d use are:

    1. Perform a dilation on the shape to get a new area which is the shape plus its boundary
    2. Subtract the original shape from the dilated shape to leave just the boundary
    3. Use the boundary to index your data matrix, then take the minimum.

    Dilation

    What I want to do here is pass a 3×3 window over each cell and take the maximum value in that window:

    [m, n] = size(A); % assuming A is your original shape matrix
    APadded = zeros(m + 2, n + 2);
    APadded(2:end-1, 2:end-1) = A; % pad A with zeroes on each side
    ADilated = zeros(m + 2, n + 2); % this will hold the dilated shape.
    
    for i = 1:m
        for j = 1:n
            mask = zeros(size(APadded));
            mask(i:i+2, j:j+2) = 1; % this places a 3x3 square of 1's around (i, j)
            ADilated(i + 1, j + 1) = max(APadded(mask));
        end
    end
    

    Shape subtraction

    This is basically a logical AND and a logical NOT to remove the intersection:

    ABoundary = ADilated & (~APadded);
    

    At this stage you may want to remove the border we added to do the dilation, since we don’t need it any more.

    ABoundary = ABoundary(2:end-1, 2:end-1);
    

    Find the minimum data point along the boundary

    We can use our logical boundary to index the original data into a vector, then just take the minimum of that vector.

    dataMinimum = min(data(ABoundary));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that returns a comparison matrix from a given list: def
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
I need to create a function to rotate a given matrix (list of lists)
given a matrix of distances between points is there an algorithm for determining a
Given matrix product C = A*B , is there N^2 way to estimate max
given an n*m matrix with the possible values of 1, 2 and null: .
Given an n-dimensional matrix of values: what is the most efficient way of retrieving
Given an arbitrary 4x4 transformation matrix, how do I find out the center of
Given graph, how could i represent it using adj matrix?. I have read lots
I have a string of style transform given in the following way : matrix(0.312321,

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.