How to select framework of an image?

3 views (last 30 days)
Sokratis Panagiotidis
Sokratis Panagiotidis on 27 Jan 2022
Answered: Image Analyst on 3 Mar 2022
I am working on a programm to analyze over a Million pictures for my Bachelor's thesis and I'm quite stuck on this matter here:
The pictures/images have a size of 1024x1024 pixels. Now I need to (as quickly as possible) control the outer framework of each image. Anybody know how to help me with that? I'm posting what I've already made by selecting an 800x800 pixel area of each image in hopes to modify it into selecting onl the outer frame - to no avail.
Also the pictures are binarized, in case it might matter.
frame = BW2([1 1024 2:1023], [1:1024 1 1024]);
Please tell me if you need more info.
EDIT: I meant "as quickly as possible" in terms of not taking up too much time while running. This program should be able to analyze many images as quickly as possible so it won't have to run that long.

Answers (2)

KALYAN ACHARJYA
KALYAN ACHARJYA on 27 Jan 2022
You can consider a frame of selection, force remaining pixels to black(0) or white(255), let's suppose data is a gray image-
data([1:50,50+end],:)=0;
%.......^ change accordingly
data(:,[1:50,50+end])=0;
figure, imshow(data);
  1 Comment
Sokratis Panagiotidis
Sokratis Panagiotidis on 28 Jan 2022
Hi it didn't work out as my program crashes while using it.
But I ain't sure this is what I was looking for. It seems like it sets the value of the selected area to a 0 (talking about binary image here).
Maybe I should explain better what I'm exactly looking for:
I need to look at the outer frame of a 1024x1024 image (meaning everyting that's not inside [2:1023] in both axes) and see if it has the value 0.
Do you know how I should proceed?

Sign in to comment.


Image Analyst
Image Analyst on 3 Mar 2022
I'm not sure what you mean exactly by "control".
This syntax is not really right for a 2-D binary image
frame = BW2([1 1024 2:1023], [1:1024 1 1024]);
I think you would get the whole image again. If you want to crop out an 800 by 800 subimage at 112, 112, do this
topRow = 112;
leftColumn = 112;
frame = BW2(topRow : topRow + 799, leftColumn : leftColumn + 799);
If you want to get the outer edges individually you can get them like this:
topRow = BW2(1, :);
bottomRow = BW2(end, :);
leftColumn = BW2(:, 1);
rightColumn = BW2(:, end);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!