Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:11:40+00:00 2026-06-06T06:11:40+00:00

My final lab task is cropping parts from an image, inserting the cropped image

  • 0

My final lab task is cropping parts from an image, inserting the cropped image to original back, rotating, and resizing it.

We have the image as a 2D array in a txt file, and Matlab converts the text files to images/image files to txts, so we can see our results.

With my code when I crop a square(image.extract_sub_image(0,0,100,100);), no problems but it inserts the cropped image to the opposite coordinates I don’t know why. Also when I crop a rectangle(image.extract_sub_image(0,0,100,50);) the program crashes. Also don’t know why 🙁

PS:

Read, write, get_dimensions functions are given by the prof.They are constant, and the header file is also given by the prof, **p2matr2D was his idea and I can’t change it.

My code : http://codepad.org/F0mfR7dN

goldhill.txt file : http://codepad.org/jfbeKLII

If I am not mistaken according to x,y coordinate system, x should be columns and y should be rows, and this is what I mean for opposite insertion : https://i.stack.imgur.com/UbfZf.png , green box is what I want, red box is what comes out …

The first 2 values in the text file determine the image dimensions, that’s how the prof arranged his Matlab script and C++ code.

I would be glad for your tips and comments to solve the problems.I know the code is long but I think I needed to paste everything in order to explain what I’m facing. The problem should be in CCTOR, =op, extract or insert functions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:11:41+00:00Added an answer on June 6, 2026 at 6:11 am

    It would seem to me that in some way, you’re inverting your columns with your rows. That would explain why when height is not the same as width, you get an exception and why it flips your picture when they are the same.

    I didn’t look at your code, but I would imagine you’re simply using the row index for the column array and the column index for the row array in your 2-dimensional array. That’s the simplest cause.

    Also, a tip for you: If you rewrite it as a 1-dimensional array of size height*width, you will get a drastic speed increase. Write a method which accepts an x and y coordinates and translates these coordinates into a single index for your 1-dimensional array and return the value so you don’t have to worry about details once you’ve made this method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
I am trying to convert a PIL image into an array using NumPy. I
My final task is to fully recover object previously saved using JSON. For now
I have Blend 3 Final and Visual Studio 2010 Beta 1 installed and I
final ListView lv= (ListView)findViewById(R.id.list); String[] from = new String[] {a, b,c}; int[] to =
I often use Octave to create data that I can plot from my lab
final CharSequence[] items = {Red, Green, Blue} AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(Pick a
final TableLayout table = (TableLayout) findViewById(R.id.tableLayout); TableRow row = new TableRow(this); TextView t2 =
final HttpClient hClient = new DefaultHttpClient(); final HttpPost hPost = new HttpPost( http://xxx.xxx); try
Final Edit: I was able to locate the duplicate field in the ini file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.