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 回表示 (過去 30 日間)
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

回答 (1 件)

yanqi liu
yanqi liu 2021 年 2 月 26 日
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);

カテゴリ

Help Center および File ExchangeFractals についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by