i wrote a code to convert color image into blocks... the output looks like the input image in grayscale with gridlines over it... can i get the output with gridlines over the color input image i give.... please do reply
rgbimage = imread('peppers.png'); patchsize = 10; imsize = 10*25; rgbimage = imresize(rgbimage ,[imsize imsize]); image_out = ; for i = 1:patchsize:imsize image_out_tmp = ; for j = 1:patchsize:imsize tmp_img = rgbimage ((i+1-1):i+patchsize-1,(j+1-1):j+patchsize-1); tmp_img = [ones(patchsize,1) tmp_img ones(patchsize,1)]; tmp_img = [ones(1,patchsize+2);tmp_img;ones(1,patchsize+2)]; image_out_tmp = [image_out_tmp tmp_img]; end image_out = [image_out;image_out_tmp]; end figure;imshow(image_out);
No products are associated with this question.
% Extract the individual red, green, and blue color channels. redChannel = rgbImage(:, :, 1); greenChannel = rgbImage(:, :, 2); blueChannel = rgbImage(:, :, 3);
% Now draw your lines in the channels for every row and column that you want. redChannel(row, :) = 0; greenChannel(row, :) = 0; blueChannel(row, :) = 0; redChannel(:, column) = 0; greenChannel(:, column) = 0; blueChannel(:, column) = 0;
% Recombine separate color channels into a single, true color RGB image. rgbImage = cat(3, redChannel, greenChannel, blueChannel);
clear all; A = imread('lenaT.jpg');% size of image 512 x 512 [r c]=size(A); bs= 256; % Block Size (256x256)
nob=(r/bs)*(c/bs); % Total number of 256x256 Blocks
% Dividing the image into 4x4 Blocks kk=0; for i=1:(r/bs) for j=1:(c/bs) Block(:,:,kk+j)=A((bs*(i-1)+1:bs*(i-1)+bs),(bs*(j-1)+1:bs*(j-1)+bs)); end kk=kk+(r/bs);
A1 = (Block(:,:,1)); A2 = (Block(:,:,2)); A3 = (Block(:,:,3)); A4 = (Block(:,:,4));
figure(1) subplot(2,2,1);imshow(A);title('Original Image'); subplot(2,2,2);imhist(A);title('histogram of the Orignal Image'); figure(2) subplot(2,2,1);imshow(A1);title('First Block'); subplot(2,2,2);imshow(A2);title('Secound Block'); subplot(2,2,3);imshow(A3);title('Third Block'); subplot(2,2,4);imshow(A4);title('Fourth Block');
Why are you only accessing two dimensions of the three-dimensional array you named "image" ?
People would not usually refer to what you are doing as converting the image into "patches": they would talk about converting it into "blocks". When I saw the title and description I tried debugging your code with the expectation that you were trying to build up arguments for patch() calls.
Play games and win prizes!Learn more