Effacer les filtres
Effacer les filtres

I have an image where I divided image matrix into cell array each of size 4*4 using mat2cell().Tell me how to get the coordinates of each selected cell array

2 vues (au cours des 30 derniers jours)
I have wriiten the code as follows:
rgbImage = imread('male.jpg');
[rows columns numberOfColorBands] = size(rgbImage);
padimg=padarray(rgbImage,[0 80],'replicate','post');
size(padimg);
[rows1 columns1 numberOfColorBands1] = size(padimg);
blockSizeR = 4; % Rows in block.
blockSizeC = 4;
wholeBlockRows = floor(rows1 / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows)];
size(blockVectorR);
wholeBlockCols = floor(columns1 / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols)];
size(blockVectorC);
ca = mat2cell(padimg, blockVectorR, blockVectorC, numberOfColorBands);
%celldisp(ca);
%imshow('padimg')
%ca{40,40}
%ca{1,1}
%[xc,yc,pixval]=impixel(ca{1,1});
here when I use impixel it displays picture to select pixels..instead i need to get all pixel positions of that cell array without selection

Réponses (1)

Walter Roberson
Walter Roberson le 21 Fév 2016
ca{J,K} is image coordinates (J-1)*4+1 : J * 4, (K-1)*4+1 : K * 4
  2 commentaires
alapati pujitha
alapati pujitha le 22 Fév 2016
logic you have given prints the pixel intensities.I require x and y coordinates of each selected cell array
Walter Roberson
Walter Roberson le 22 Fév 2016
Modifié(e) : Walter Roberson le 22 Fév 2016
No, the coordinates are (J-1)*4+1 : J * 4 and (K-1)*4+1 : K * 4, in all combinations. If you need a complete table of them then:
[gridR, gridC] = ndgrid((J-1)*4+1 : J * 4, (K-1)*4+1 : K * 4);
RC = [gridR(:), gridC(:)];
Now RC will be a 16 x 2 matrix of rows and columns.
Note: Rows correspond to Y coordinates, and columns correspond to X coordinates.
If you have an X, Y coordinate system that is not the same as rows and columns, then small adjustments can be made. For example, if Xcoords and Ycoords are the vectors of X coordinates corresponding to each column and Y coordinates corresponding to each row, then
[gridR, gridC] = ndgrid((J-1)*4+1 : J * 4, (K-1)*4+1 : K * 4);
XY = [Xcoords(gridC(:)), Ycords(gridR(:))];
which will be a 16 x 2 matrix of X and Y coordinates.
And not a single pixel intensity involved.

Connectez-vous pour commenter.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by