I want to partition an image into 8x8 ranges(non-overlapping) and 16x16 domain (overlapping) blocks. I have used the code mentioned below for 8x8 ranges(non-overlapping). I'm not sure if I can use mat2cell for creating 16x16 domain blocks.

1 Ansicht (letzte 30 Tage)
clc;
% Read Image
A = imread('football.jpg');
B = imfinfo('football.jpg');
[r1, c1, depth] = size(A);
imshow(A)
blockSizeR = 8; % Rows in block.
blockSizeC = 8; % Columns in block.
wholeBlockRows = floor(r1 / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(r1, blockSizeR)];
wholeBlockCols = floor(c1 / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(c1, blockSizeC)];
if depth > 1
ca = mat2cell(A, blockVectorR, blockVectorC, depth);
else
ca = mat2cell(A, blockVectorR, blockVectorC);
end

Antworten (1)

yanqi liu
yanqi liu am 26 Feb. 2021
sir,may be use this
clc; clear all; close all;
I = imread('cameraman.tif');
sz = size(I);
th = 8;
[x, y] = meshgrid(linspace(1,sz(2),th), linspace(1,sz(1),th));
z = ones(size(x));
figure;
imshow(I, []);
hold on; axis off;
mesh(x, y, z, 'FaceColor', 'none', ...
'EdgeColor', 'r', 'LineWidth', 1, ...
'Marker', 'o', 'MarkerFaceColor', 'k', ...
'MarkerSize', 3);

Kategorien

Mehr zu Fractals finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by