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 CenterFile Exchange에서 Fractals에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by