From: Teresa Rothaar on 6 Jul 2010 11:29 I need to write a script that will do the following: * Read a black & white image * Somehow partition the image into small patches (user should be able to specify size) * The image pops up in a figure window with the squares on top * The user can click on the squares, and the index of the SQUARE (NOT the x,y) point is saved to a file I know how to read images, make them display in figure windows and save x,y points to a file. I've even found a few scripts that will overlay grids on top of images. However, I'm having trouble with: 1) having the user be able to specify the size of the grid -- in fact, I've only been able to get it to specify how many pixels across & down each square should be, not how many squares there should be total and 2) having the user be able to click and save the square index, NOT the x,y points. In other words, somehow, I need the image to display with a matrix overlaying it, and then save the indices of the matrix. Does anyone have any ideas as to what functions I should be looking at? I'm not new to MATLAB, but I am very new to image processing. Here is the code stub I have to display an image and overlay a grid to it: % Display the image and call |hold on|. img = imread('10thdoctorbw.jpg'); imshow(img) hold on % Superimpose the grid. M = size(img,1); %Determine number of vertical pixels in img N = size(img,2); %Determine number of horizontal pixels in img %Draw vertical grid lines for k = 1:100:M x = [1 N]; y = [k k]; plot(x,y,'Color','y','LineStyle','-'); plot(x,y,'Color','k','LineStyle',':'); end %Draw horizontal grid lines for k = 1:100:N x = [k k]; y = [1 M]; plot(x,y,'Color','y','LineStyle','-'); plot(x,y,'Color','k','LineStyle',':'); end hold off
|
Pages: 1 Prev: how delete repeated rows? Next: printing Simulink models with scripts |