sir i have a white and black(BW) (binary)image of size (i X j).i need image to be scanned from left to right, up and down and the scan area is 3X3.if one of 8-neighbour pixel is white (255).then center point should becomes white (255). sir please help in coding
sir i am able to divide image into blocks of size 3X3
BW=imagen;
BW2 = zeros(3 * ceil(size(BW)/3));
BW2(1:size(BW,1),1:size(BW,2)) = BW;
BW = BW2;
r = mat2cell(BW, 3 * ones(1,size(BW,1)/3), 3 * ones(1,size(BW,2)/3));
then i am trying with B(2,2) = max(r(2,2),255 * any(r(:)==255)); %for (2 2)block
but i am geting error
??? Function 'eq' is not defined for values of class 'cell'.
Error in ==> eq at 18 [varargout{1:nargout}] = builtin('eq', varargin{:});
sir please help in coading

 Akzeptierte Antwort

Oleg Komarov
Oleg Komarov am 10 Apr. 2011

0 Stimmen

Why did you group in cells in thr first place?
Referencing the content of a cell should be done with curly brackets:
r{1,1}

4 Kommentare

javeed miyandad
javeed miyandad am 10 Apr. 2011
sir i used B{2,2} = max(r{2,2},255 * any(r{:}==255));
but geting error
??? Error using ==> eq
Too many input arguments.
Oleg Komarov
Oleg Komarov am 10 Apr. 2011
Try to execute r{:}. It calls the content of every cell SEQUENTIALLY and not all together.
That's why I asked you why did you use cells.
You could keep the whole double matrix and reference the blocks (r{2,2} in this case) with logical indexing.
javeed miyandad
javeed miyandad am 10 Apr. 2011
sorry sir i am not geting
plz can u give another code
Oleg Komarov
Oleg Komarov am 10 Apr. 2011
B{2,2} = max(r{2,2}, 255*cellfun(@(x) any(x == 255),x));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by