Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

In matlab, how to draw a grid over an image

Date: 2023-01-03 14:28:26

How to draw a grid over an image. It should become part of that image itself. It should be able to show some rows and columns over the image itself. The lines for rows and columns can be specified. Actually I was encouraged by the way some research paper discusses about the results they have about image warping. One of the links is this: http://www.hammerhead.com/thad/morph.html

Expert Answer:

s:

There are a number of related questions on SO that discuss ways to modify an image. Here are the two general approaches:

1. Modify the image data directly: I discuss this in my answer to this other SO question. Since image data can be 2-D or 3-D, you can use multidimensional indexing to modify the raw image data, creating lines along given rows and columns. Here's an example that changes every 10 rows and columns in the image to black:

 

img = imread('peppers.png');  %# Load a sample 3-D RGB image
img(10:10:end,:,:) = 0;       %# Change every tenth row to black
img(:,10:10:end,:) = 0;       %# Change every tenth column to black
imshow(img);                  %# Display the image

And now the image data in the variable img has black lines on it, and you can write it to a file or do whatever other processing you want to it.

2. Plot the image and the lines, then turn the axes/figure into a new image: The link to Steve Eddins' blog in zellus' answer shows an example of how you can plot an image and add lines to it. However, if you want to save or perform processing on the displayed image, you will have to save the displayed image as an image matrix. How you can do this has been discussed in these other SO questions:

  • How can I save an altered image in MATLAB?
  • Turn Matlab plot into image

Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

Our Comprehensive Matlab Assignment Help Services

Personalized Tutoring:Our team of MATLAB experts offers one-on-one tutoring sessions tailored to your specific needs. Whether you’re struggling with basic concepts or advanced algorithms, we provide clear, step-by-step guidance to help you understand and master MATLAB.

Assignment Assistance:Facing tight deadlines or complex assignments? We’re here to help! From initial problem analysis to code development and debugging, we offer full-spectrum support to ensure your assignments meet the highest standards.

Project Development: Need help with a research project? Our specialists can assist you in designing and implementing robust MATLAB solutions. We cover everything from project planning and data collection to coding, simulation, and result analysis.

Coursework Support: We provide comprehensive support for your coursework, helping you understand lectures, complete lab exercises, and prepare for exams. Our goal is to ensure you grasp the core principles and practical applications of MATLAB.

Thesis and Dissertation Guidance:Writing a thesis or dissertation? Our experts can assist you in incorporating MATLAB for data analysis, modeling, and simulation. We help you develop a strong methodological framework and ensure your research stands out.

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com