필터 지우기
필터 지우기

how to create and solve an image puzzle?

조회 수: 2 (최근 30일)
mohamad k
mohamad k 2018년 6월 29일
below code create a 3*3 image puzzle
%%load and crop image
imdata = imread('Cars HD (17).jpg');
new_dims = size(imdata) - rem(size(imdata), 3)
imdata = imdata(1:new_dims(1),1:new_dims(2), :);
%%Arrange into 3x3 cell
block_dims = new_dims./[3 3 1];
blocks = mat2cell(imdata, block_dims(1)*ones(3,1), block_dims(2)*ones(3,1), block_dims(3));
%%Rearrange randomly
blocks(1:9) = blocks(randperm(9));
%%Set one block to zero
blocks(ceil(9*rand(1))) = {zeros(block_dims, class(imdata))};
%%Return to image
puzzle = cell2mat(blocks);
%%Plot input and output
figure(1)
image(imdata)
figure(2)
image(puzzle)
but in addition i need to solve it through displacing blocks via clicking .could you help me how to displace two blocks via clicking on them? thanks

답변 (0개)

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by